Sleep is universal among animals with nervous systems, is regulated with precision, and is fatal to eliminate. What it is for remains unresolved, and the leading proposals are not variations on one answer but genuinely different ones.

Sleep is not merely rest. It is a distinct, actively generated state with characteristic brain activity, reduced responsiveness, a species-specific posture, and rapid reversibility, which is what separates it from coma or hibernation.

It is homeostatically regulated. Sleep lost is subsequently recovered, and the pressure to sleep builds measurably with time awake, tracked in slow-wave activity. That regulation is the strongest argument that sleep performs a function rather than merely filling time.
It is essentially universal. Every animal with a nervous system examined for it shows a sleep-like state, including insects, molluscs and the jellyfish Cassiopea, which has no brain at all.
Its absence is lethal. Rats totally deprived of sleep die within weeks. Fatal familial insomnia, a human prion disease, destroys the ability to sleep and is invariably fatal.
The consequences of restriction are well documented: impaired attention, memory and mood, disrupted glucose regulation, and increased cardiovascular risk.
Sleep is also costly. An animal asleep is not foraging, not mating, and not watching for predators, and evolution has retained it anyway, which is the strongest possible argument that it buys something important.
Several accounts are supported by real evidence, and they are not mutually exclusive, which is part of why the question is hard to close.
Memory consolidation. Newly encoded material is reactivated during sleep, and hippocampal replay of waking activity sequences has been recorded directly. Sleep after learning improves retention, and targeted reactivation using sounds or odours during sleep can enhance specific memories. The difficulty is that the effect sizes in humans are modest and variable, and consolidation seems unlikely to explain why sleep is lethal to remove.
Synaptic homeostasis. Giulio Tononi and Chiara Cirelli proposed that waking experience strengthens synapses across the board, which is unsustainable in energy and in signal-to-noise terms, and that sleep proportionally downscales them, preserving what is relatively strong. Structural evidence of net synaptic reduction during sleep supports it, and the details of which synapses are spared are not settled.
Metabolic clearance. Work published in 2013 reported that the interstitial space in the brain expands during sleep, increasing the flow of fluid that removes waste products including amyloid beta, and this glymphatic account was rapidly and widely adopted. It has since been directly contradicted: a study published in Nature in 2024 reported that clearance was reduced rather than increased during sleep and anaesthesia. The disagreement is about measurement technique and is unresolved, and this is the clearest instance in the field of a popular explanation being destabilised after entering textbooks.
Energy conservation and reallocation. Metabolic rate falls during sleep, though not by much in humans, and the saving is too small on its own to justify the risk. A stronger version holds that sleep reallocates resources toward biosynthesis and repair rather than simply reducing expenditure.
Immune function. Sleep loss impairs immune response and reduces vaccine efficacy, and infection increases sleep, which suggests a genuine link.
Development. Newborns sleep enormously and spend a large share of it in rapid eye movement sleep, which has prompted the proposal that its primary role is in building and calibrating the nervous system rather than maintaining it.

Every deprivation experiment confounds the loss of sleep with the stress of preventing it, and disentangling the two has proved persistently difficult.
Sleep is not one state. Rapid eye movement and non-rapid eye movement sleep differ in nearly every measurable respect, and may serve different purposes, so a single functional answer may be the wrong shape of answer.
Function may also differ across species and across the lifespan, and results from rodents, flies and humans do not always agree.
There is also a plausible position that sleep has no single primary function, having originated for one reason and accumulated others, in which case the search for the function is misconceived.
The unresolved theory does not undermine the practical findings, which rest on their own evidence.
Chronic short sleep is associated with worse cognitive, metabolic and cardiovascular outcomes. Sleep is important for consolidating learning. Circadian misalignment, as in shift work, carries risks separate from sleep duration.
Public claims in this area have sometimes gone beyond the evidence, and some widely repeated statements about the dangers of short sleep have been criticised by researchers for overstating what individual studies support.
Sleep is the largest single behaviour in a human life, and the most basic question about it is open. That is worth stating plainly, because the volume of confident advice on the subject can suggest otherwise.
It is also a useful correction to the assumption that ubiquity implies understanding. A phenomenon can be universal, easily observed, intensively studied for a century, and still lack an agreed explanation.