YOur body must rest a number of hours a day. During this time what is your spirit doing, it needs no rest.. its a lot of time when you get right down to it.
Experiments with computers modleled after our brain, nueral-nets, have shown that dreaming is a necessity of this sort of wiring. The nuerl net needed to rest every couple of hours and generate random data or else all the tiny errors in the net would multiply and cause massive system failure. In the same way, we need to sleep and generate random data, dreams, so as to keep our brains healthy.
So you run the network in wake-sleep cycles, and it learns. The authors got a big collection of handwritten digits from the post office. They fed the digits to the network, and it learned to recognize them - without anyone telling it what to look for.
They also printed out the network's dreams--the simulated input patterns. Images of the 10 digits appeared in the dreams. What's more, the images were not idealized representations of the digits. Rather, they were all variations on the ideal, and the variations in the dreams very much resembled the variations found in the actual input data. A sample of the input and a sample of the dreams looked pretty much the same.On this theory, you could start to understand why people hallucinate when they aren't allowed to dream. If you don't dream, then your brain can't keep its perceptual categories optimized for your current reality. And a divergence between perception and reality is essentially the definition of a hallucination.
You could also start to understand the experience of dreaming: a dream would appear to be the subjective experience of your brain running backwards.
.. http://world.std.com/~swmcd/steven/stories/dream.html
.. http://www.imagination-engines.com/newpcai.htm
-Dan