Tldr:<p>When we sleep, our brains process the events of the day and pick out things to stow away in our long term memory.<p>Maybe as a side-effect of this processing, they also aid problem solving - after a good night's sleep, you are able to find solutions to the previous day's problems faster (than you would, if you hadn't had the sleep).<p>As we sleep, our brains clear away toxins that accumulate during our awake time. These toxins may be culprits behind neuro degenerative diseases.<p>There seems to be a correlation between sleep deprivation and cardiovascular diseases.
It is, I think, often more enlightening to ask the question "why do we awaken"?<p>I wonder if, a long time ago, some animal evolved the ability to enter brief periods of elevated activity. This was obviously highly advantageous for e.g. escaping predators, so over time this animal evolved to sustain this temporary boost for longer periods. Today, animals can sustain this boosted state for the majority of their lifetime. It is merely a matter of perspective that leads us to consider wakefulness to be "normal" and sleep to be something out of the ordinary.
I hate it when I solve programming problems while sleeping. It makes me feel like I'm working for free on my time off. They're only supposed to be renting my brain for part of the day.
I have an alternative answer to that question. Mammals evolved to sleep because those young that gave their parents a rest survived childhood. Seems obvious to any parent. :-) Imagine a puppy that never stopped. Its mother would abandon it.
There's a pretty convincing theory that says that while we sleep, brain is processing signals from our internal organs instead of processing the sensory input. Experimentors were triggering impulses in monkey stomach and seeing them activate some areas of the brain that are normally used in the cognitive process. That way brain inspects the organism and balances it's functions. One of the side effects of this theory is that our dreams are just an interpretation of these signals. Like your liver signals trigger some areas of the brain and that produces the weird imaginery we call dreams. Can't find the link to that paper right away.
This is where f.lux - <a href="https://justgetflux.com" rel="nofollow">https://justgetflux.com</a> - is so great. After sunset in your location it gradually bleeds blue light from your display: also at work I use it to just orange-ify the display a bit at a constant rate - because work is lit by fluorescents - and on a bright monitor it noticeably reduces eyestrain.