This is the second piece in a three-part series on sleep. Read part one, on falling asleep, and part three, on wakefulness.

It’s strange, when you think about it, that we spend close to a third of our lives asleep. Why do we do it? While we’re sleeping, we’re vulnerable—and, at least on the outside, supremely unproductive. In a 1719 sermon, “Vigilius, or, The Awakener,” Cotton Mather called an excess of sleep “sinful” and lamented that we often sleep when we should be working. Benjamin Franklin echoed the sentiment in “Poor Richard’s Almanack,” when he quipped that “there’ll be sleeping enough in the grave.” For a long time, sleep’s apparent uselessness amused even the scientists who studied it. The Harvard sleep researcher Robert Stickgold has recalled his former collaborator J. Allan Hobson joking that the only known function of sleep was to cure sleepiness. In a 2006 review of the explanations researchers had proposed for sleep, Marcos Frank, a neuroscientist then working at the University of Pennsylvania (he is now at WSU Spokane) concluded that the evidence for sleep’s putative effects on cognition was “weak or equivocal.”

But in the past decade, and even the past year, the mystery has seemed to be abating. In a series of conversations with sleep scientists this May, I was offered a glimpse of converging lines of inquiry that are shedding light on why such a significant part of our lives is spent lying inert, with our eyes closed, not doing anything that seems particularly meaningful or relevant to, well, anything. (The meetings were facilitated by a Harvard Medical School Media Fellowship.)

One line of evidence stems from what happens when sleep is disturbed. By looking at what can go wrong while we’re asleep, we can get a sense of what sleep is for. Take genetic impairments. In REM-sleep behavior disorder, the usual paralysis that keeps our bodies in check as we enter REM sleep disappears, and people physically act out their dreams. The disorder is a fairly reliable predictor of neurodegenerative disease: one study, based at the Center for Sleep Research at the Hôpital du Sacré-Coeur, in Montreal, found that over half of the patients who acted out their dreams had developed some form of neurodegenerative disease twelve years later. There’s sleep apnea, when your breathing pauses as you sleep, often for a few seconds but sometimes for a few minutes, before your body briefly jolts awake to restart the process. (Often, the jolt never makes it into conscious memory.) In trials, the disorder has been associated with diabetes and cardiovascular disease and has been shown to lead to cognitive impairment. About ten per cent of the population experience impairment during their waking hours as a result of chronic insomnia, a condition that has been linked to low quality of life, depression, increases in cardiovascular disease and hypertension, cognitive and motor impairment, and a number of other medical conditions.

For sleep scientists, all of these unpleasant disorders offer tantalizing lines of inquiry. The link between many of them and neurodegenerative disease, or other forms of cognitive impairment, suggests that sleep could be required for cognitive upkeep and function. Their link with heart disease suggests that sleep might serve to relieve vascular stress. The fact that insomnia is associated with depression suggests that sleep might help us deal with emotionally stressful or otherwise disruptive events.

Increasingly, researchers have found ways to test these theories more directly. In 2000, Stickgold published a study in Science that became one of the most convincing validations of the role that sleep and dreams play in memory consolidation. For seven hours, over the course of three days, a group of people played the computer game Tetris. Some had never played the game before; others were familiar with it; and a third group didn’t know either way, because they were amnesiacs with extensive damage to their medial temporal lobes and hippocampi. Their particular form of amnesia meant that they were unable to form new episodic memories.

Each night, as they were falling asleep, Stickgold’s subjects were repeatedly awoken and asked to recall, to the best of their knowledge, what they were dreaming about. It turned out that they dreamed of Tetris. What was surprising was that even the amnesiacs had these dreams. They had no idea what they were seeing and, the next morning they remembered neither the game nor the experimenter, but they would recall dreams of falling shapes that conformed to the Tetris patterns they’d observed earlier in the day. Sometimes, they’d even report that the shapes rotated to fit into rows.

Since then, evidence for the memory-related functions of sleep, and of dreams in particular, has only mounted. In 2013, Stickgold published a summary of his research since the Tetris study, also reviewing parallel advances by other researchers in the field. In that paper, he argued that sleep isn’t crucial just for memory consolidation; it is also a remarkably selective mechanism. We don’t remember everything that happens to us on a given day: sometimes, we remember something simply because it’s emotional, while, at other times, we work our way through mundane details to figure out why something matters. Sleeping and dreaming, Stickgold argues, help us sift through material to isolate and store the important take-away, whether it is what he calls the “gist” (the overarching point of a lot of information) or a specific detail. “When we dream, we get the pieces. When we wake, we can know the whole,” Stickgold says.

In one experiment, the University of Tübingen neurobiologist Jan Born and Ullrich Wagner, a neuroscientist at the University of Münster, taught a group of people a relatively complex math task. Though the subjects didn’t know it, there was a simpler way of solving the problem—an abstract rule that would enable a quick solution. Few of the subjects spontaneously figured out the solution the first time. Each participant was retested on the task eight hours later; some were allowed to sleep and others had to remain awake. Just under a quarter of the group that took a sleepless break came up with the faster solution. But the insight rate more than doubled among the subjects who had spent the eight hours sleeping: sixty per cent of them could now see the shortcut. As we sleep, our brains replay, process, learn, and extract meaning. In a sense, they think.

Our physical health, too, seems to be intimately tied with sleep. In one study, designed to test the impact that cardiac function has on sleep, and vice versa, a group of physiologists subjected healthy men with no history of cardiac problems to sleep deprivation. At various points, they measured their vascular fitness, checking their heart rates, their blood pressure, and their levels of certain proteins associated with heart problems. Within two days, almost every marker was elevated. Conversely, in a study looking at sleep apnea, which is strongly linked to cardiovascular disease, treatment of the apnea was found to improve vascular function in short order: once patients could sleep soundly, the stress on their hearts was relieved.