There is no single theory that states the function(s) of sleep. Sleep would have the property to reduce connections in the brains efficiently, and thus to make room for fresh memories and storage for the next day.

sleepYou rather die from lack of sleep (10 days) than by hunger (a few weeks). Sleep is essential for good health (and recovery from illness, fractures...)
There are indications that there is a relationship between learning and sleep, a kind of consolidation of memory. A period of sleep between the learning and the test promotes good results. The idea is also consistent with the fact that young children (who have much to learn) sleep more than older people.
There is also evidence that specific activity of the brains that during the learning process has taken place, is repeated during sleep. And there are correlations between the amount of learning before sleep and EEG patterns, in both humans and animals.

The hours of sleep before midnight count double? Not true.
It is true that the first few hours of sleep "count double", but it needs not to be before 00:00. The first few hours you sleep deeper and more stable (firmer), in the core sleep. They gain to speak more than the later hours.

The need for sleep is a vague definition that is between 4/5 hours (the absolute minimum) and 12 hours.
Want to know how much sleep you need, then you should count your sleep hours at a time when you have no obligations (vacation) and not are getting out of a difficult period with less sleep or illness. Measure approximately 2 weeks your sleep duration, then you know your need for sleep.

Catching up on sleep works. A weekend long sleeping is not always enough to settle your sleep debt. You can also sleep in advance.

Are you sleeping at least 10 to 15 minutes, then a catnap makes sense. A short nap (between 13 and 15 hour) is better than a long, it has a healing effect for body and mind.

In the past (17th century) beds were much shorter because people then slept more sedentary than lying down.

Sleep would also be interrupted 1 (or 2) times to maintain the fire. A reflex at the time (and older), which some would still have inherited (partially).

University of Toronto followed the sleep pattern of the Hadza tribe in Tanzania, which still lives as hunter-gatherers. In a total sleeping period of more than 200 hours, it occurred only 18 minutes that all members of the tribe slept at the same time. On average, eight people (40 percent of the group, mostly young people) were alert.

In tropical countries the habit to spend the hottest part of the day resting or sleeping happens often. Keeping a siesta is healthy.

"Doctor, I cannot sleep, I lie but turning.” "No wonder, you have to lie still!" (Theo Bergsma)
Falling asleep is only during sleepwalking. (Rob Bonnet)
"You were quite restless. You were all night swearing in your sleep.” "Who said I slept?" (Max Tailler)
What can you expect from a day that starts with getting up? (Wendy R. Ellner)
"How many times do I have to take a sleeping pill?" "Every night every two hours."
Four hours of sleep a day is enough for a man. The rest he can catch overnight.
I used to dream just dreams. Now I dream also the explanation. (Kamagurka)
Dreams were made ​​to not get bored while sleeping. (Francis Blanche)