By Philip Moeller for U.S. News

Your mind may be the closest thing to the Holy Grail of longevity and happiness. Education has been widely documented by researchers as the single variable tied most directly to improved health and longevity. And when people are intensely engaged in doing and learning new things, their well-being and happiness can blossom.

This effect becomes even more valuable as we get older. Even in old age, it turns out, our brains have more plasticity to adapt and help us than was once thought. Old dogs, in short, can learn a lot of new tricks.

"I think most social scientists would put their money on education as the most important factor in ensuring longer lives," says psychologist Laura Carstensen, director of the Stanford Center on Longevity. People with more education get better jobs that pay more money, are less physically demanding, and provide more enjoyment. They live in safer neighborhoods, practice healthier lifestyles, and have less stress.

In a paper published earlier this year by the National Bureau of Economic Research, authors David Cutler and Adriana Lleras-Muney reviewed education-longevity research around the world. "Education not only predicts mortality in the U.S., it is also a large predictor of health in most countries, regardless of their level of development." They cited research that 25-year-olds with some college education in 1980 could expect to live another 54.4 years, on average, whereas 25-year-olds with high school degrees had life expectancies of another 51.6 years, or nearly three years less. A similar study in 2000—only 20 years later—found that the life-expectancy gap between those with some college and high school graduates had increased to seven years.

Some studies attribute all or most of the education benefit to simply making more money, but not all researchers agree. "While income level best predicts how quickly people decline after they get sick," Carstensen says, "education predicts whether or not people get sick in the first place." People with more education tend to have better problem-solving skills and the tools to help themselves, she explains. They enhance their health and survival odds by making well-informed lifestyle decisions.

The income effect is important, "but I think it goes beyond that," says Lisa Berkman, professor of public policy and epidemiology at Harvard University. One of Berkman's students did an in-depth study of different school attendance requirements set by state laws 70 and 80 years ago. "If you lived in a state where the schooling laws made you go to school for a longer period of time, you had better cognitive functioning later in life," Berkman says. In other words, irrespective of income or other variables, just being in a classroom for more hours boosted mental health in later life.

In terms of happiness, a close companion of learning is the degree of engagement people have with tasks that provide them knowledge and fulfillment. People who are intensely absorbed in a task can lose track of time and place. Hours pass like minutes. They may be tired by the task but emerge energized and happy. This condition is known as "flow," a name coined 30 years ago by psychologist Mihaly Csikszentmihalyi.

Now at the Claremont Graduate University, Csikszentmihalyi recalls encountering people as a child in war-ravaged Europe who could happily lose themselves in an activity, like chess or even a risky thing like rock climbing, despite being in constant physical danger and surrounded by gruesome scenes of death. The activity was absorbing and meaningful in itself, a condition described as being autotelic. "People just liked to do" such activities, he says. "They didn't need to be told to do it. They didn't need money to do it."

"I later constructed this kind of model or theory" for such behavior, Csikszentmihalyi says. "Since nobody knew what autotelic meant, I called it flow." Research over the years has shown that people totally engaged in pursuits can trigger healthful changes in their brain chemistry and respiratory patterns.

Flow is easily associated with creativity and the image of a musician or artist "lost" in near-rapturous pursuit of their craft. And Csikszentmihalyi says in some respects, society has come to value and support the arts and sporting pursuits precisely because of their flow benefits. It's why we like to do them in the first place. "The real challenge," he says, "is to take something that you have to do that has purpose and meaning" and figure out how to induce a state of flow while doing it. "It's possible to experience your job and your family life as flow, and that to me is more important than that we provide opportunities for flow in art and sports."

Flow may appear a lofty goal of achieving total absorption in a task or activity. If so, think of various stages of engagement as forming a path toward flow that also provide satisfaction and happiness. To derive these benefits, researchers have found, the tasks involved must be sufficiently hard to really challenge us. It's that challenge that draws us in and it's overcoming that challenge that produces health and happiness. These conditions have been given a name as well: "just manageable difficulty." Like Goldilocks' porridge preference, our challenges have to be "just right" for us to thrive.

The benefits of learning and engagement are particularly important in promoting healthy aging. "Your mind is really like a muscle, and using it is a key" to lifelong mental health, Berkman says. There has been a surge in attention to mental exercise as a way of preventing Alzheimer's disease, for example. While the link between such efforts and disease prevention has not been definitively established, most scientists believe there is a beneficial relationship between lifelong learning and staying socially active with mental well-being and happiness later in life. Older people who become isolated can lose the activities that trigger their minds to engage in enjoyable and stimulating activities.

Jacquelyn James is the director of research at the Sloan Center on Aging & Work and has been overseeing an ongoing study of the benefits that older people derive from continued work. Across a span of activities—paid work, caregiving, volunteering, and education—the levels of engagement people experienced were strongly related to their enjoyment and benefits from the activity. Just being involved in an activity does not produce the benefits of engagement. And engagement needs to be connected with a sense of purpose and achievement to produce happiness.