Among the functions of sleep suggested are memory consolidation and repair of neuronal wear and tear. Jerome Siegel offers a rationale for why the duration of sleep varies so much between animals. From Carey's reivew:
Why should lions get 15 hours a night and giraffes just 5 — when it is the giraffes who will be running for their lives come hunting time? How on earth do migrating birds, in flight for days on end, sleep? Why is it that some people are early birds as young adults and night owls when they’re older?
[Siegel]...argues that sleep evolved to optimize animals’ use of time, keeping them safe and hidden when the hunting, fishing or scavenging was scarce and perhaps risky. In that view, differences in sleep quality, up to and including periods of insomnia, need not be seen as problems but as adaptations to the demands of the environment...Consider the big brown bat, perhaps the longest-sleeping mammal of them all. It snoozes 20 hours a day, and spends the other 4 hunting mosquitoes and moths in the dusk and early evening. Increased waking time would seem to be highly maladaptive for this animal, since it would expend energy and be exposed to predatory birds with better vision and better flight abilities.
In humans, it is well known that sleep quality changes with age, from the long, deep plunges of early childhood to the much lighter, more frequently interrupted five or six hours that many elderly people call a night’s sleep...In Dr. Siegel’s view, it’s a matter of tradeoffs: older people no longer have a child’s need to grow, which requires deep, long sleep and may have more need and more ability to do things for themselves instead.