I think I may have "discovered" a possible evolutionary purpose of sleeping. The first is that dreaming helps your brain reinforce old pathways to memories that may have been lost or close to lost. Well what is the brain doing while asleep? It seems that the brain randomly activates bunches of neurons without letting large chain reactions of firing neurons get out of control. The brain spends almost all of it's energy gathering, interpreting, and then storing data. So, the stored data is the most important element for long term survival. The human brain is large and complex, memories are forgotten. In order to refresh important data and or safeguard data from deletion, data that may not have been accessed actively during waking consciousness is instead activated during sleep. The more often a memory is accessed, the more connections are made towards it and the harder it is for that memory to be lost. It's very simple but seems the most logical explanation, but would also explain why people have dreams containing things that they haven't thought about in 20+ years.
The other possible reason for dreaming would be that of comparison. There is the waking state, where realities laws and properties are in effect, and then their is the sleeping state, where almost anything is possible. By letting the animal compare these two worlds, more can be understood about the waking world. When looking at something as complex as reality, it would be easier to understand it if another reality was presented to compare and contrast to it.
Just possibilities, and maybe these are just one of many functions of sleep; in fact they probably are. Any thoughts?