Having a sense of purpose in life can lower the risk of sleep problems and improve sleep quality, a new study has found, which could give doctors new options for treating the tens of millions of people who can't get a good night's sleep.

Problems such as sleep apnea (shallow breathing) and restless legs syndrome (physical restlessness) were among those covered by the study, and the findings give scientists new data on how our state of mind could affect how easily we nod off in the evening.

It's the first study to examine this connection over a longer period – a year in this case – according to the researchers from Northwestern University, as previous similar studies focussed on one particular point in life.

"Helping people cultivate a purpose in life could be an effective drug-free strategy to improve sleep quality, particularly for a population that is facing more insomnia," says lead researcher Jason Ong.

"Purpose in life is something that can be cultivated and enhanced through mindfulness therapies."

The study asked 823 adults, aged between 60 to 100 years old, 32 questions about their sleep habits and outlook on life, including their response to a series of statements.

The statements included "I feel good when I think of what I've done in the past and what I hope to do in the future" and "some people wander aimlessly through life, but I am not one of them", and were designed to tease out an outlook on life.

Those who said their lives had most meaning were 63 percent less likely to have sleep apnea and 52 percent less likely to have restless legs syndrome, as well as having moderately better sleep quality overall, the study found.

The sleep quality measured in the study can involve trouble falling asleep, staying asleep through the night, and feeling sleepy during the day, so we're talking about a whole host of issues related to not getting enough shut-eye.

And while the age range is relatively old, the researchers are confident the same connection could apply to the broader population. They also note that older people are more likely to have issues with sleeping as they age.

Having a purpose in life might be an indicator of better physical and mental health, the researchers suggest, which would in turn lead to better sleep. It's also true that those with goals to hit spend more time exercising, which again helps to improve sleep quality.

In other words there could be several factors at play here, and now the researchers want to try several mindfulness therapies to see if they can improve sleep quality.

They also note some limitations to the study, including that it was based on a self-reporting method that might not always be reliable, and it looked at a section of the population with better-than-average education and access to healthcare.

Even with those caveats though, it's an interesting take on how our mental perspective could be affecting our health around the clock – if you're finding your sleep is less than satisfactory, maybe you need to head out and find your calling in life.

"Collectively, the emerging data indicates the benefits of positive psychology on sleep health," conclude the researchers.

The findings have been published in Sleep Science and Practice.