A number of proposals and perspectives have emerged that, taken together, paint a compelling and converging picture for why sleep evolved and why it is now needed.
Why sleep evolved
The earliest differentiation into day vs. night behavior in animals was probably driven by differences in temperature and the light available for vision. Day and night are further differentiated by the aggregate "behavior" of the ecosystem (other animals also have day/night cycles). As a result, the optimal day and night survival strategies are different, and animals would have adapted to synchronize their survival strategy to the 24-hour cycle.
Evidence is accumulating that complex nervous systems, and especially the brain, perform and benefit from internal maintenance activities. Some of these maintenance activities, such as "synaptic network stabilization" occur at the cellular level. Others, such as memory consolidation or the proposed memory transfer between brain areas, occur at the whole brain level.
The brain's internal maintenancedisrupts optimal behavioral responsiveness. An animal can't be fully vigilant for predators while its brain is doing internal housekeeping. For example, memory consolidation requires information unrelated to the present moment to be accurately moved around the brain under the management of organized processes. Certainly the groggy state upon waking up is not optimal for fending off an attacker. For this reason, there is evolutionary pressure for the animal to postpone internal maintenance activitieswhile engaging with the external environment (finding food, mates, etc.) so as to reduce risk of harm.
These postponed maintenance activities have to happen sometime. To optimize survival, the organism schedules a time for them when it will be safest, which includes finding a protected place to be and initiating all maintenance activities in parallel to get them out of the way. This leads to the temporal synchronization of all postponed maintenance activities.
Collectively, these four environmental and biological pressures lead to a bifurcation of external interactive behavior and internal maintenance activity that is synchronized with the 24-hour day/night cycle. They further encourage all postponed internal maintenance activities to be synchronizedand performed in parallel, in other words,sleep.
Given the different day vs. night ecosystems, it is natural that animals that have a survival edge during one phase of the 24 hour cycle would use the other phase for sleeping. "Diurnal" animals are specialized for engaging with the daytime environment, whereas "nocturnal" animals (cats, kangaroos, owls) are specialized for night and sleep during the day. However there are other patterns as well, such as "crepuscular" animals that are active at the day/night boundary (dawn, dusk).
Why sleep is now needed
Given that a regular sleep period has formed, the question is: What goes on during sleep that is so important?
There appears to be no one single sleep activity that is the reason for sleep. Because the sleep/wake division of the 24-hour activity cycle has been around in animals for a long time -- all known animals have a quiescent period -- the sleep period has had hundreds of millions of years to acquiremultiple uses.
At the cellular level, removing toxic radicals and strengthening or rebuilding tissues has been suggested.
In the brain, a number of uses for sleep have been identified or proposed [1], including:
Restoring neurons biochemically
Rescaling the connection strengths of synapses in the brain's neural networks to facilitate easier learning the next day. This might include rewiring activity (growing synapses).
Consolidating (reorganizing and restructuring) memories. [3]
Transferring memories from the memory-specialized fast-learning brain area (the hippocampus) to the higher-capacity more cognitively powerful area (the cerebral cortex) [4]
"At the whole animal behavioural level, the functions of sleep seem clear: energy is saved, performance is restored and (in humans) affect becomes more positive. Such findings have led to the universal acknowledgement that sleep restores brain function." [1]