Across Scotland there are patterns of various-shaped stones, often dotted together in rings.

Two of these stone circles – Stenness and Callanish, on the isles of Orkney and Lewis respectively – are believed to be among the UK's oldest, dating back some 5,000 years. There are many more scattered around the Scottish countryside.

As some of the stones weigh 10 or more tonnes, transporting them was a considerable undertaking. But the real reason for their creation, and why they were placed in the locations where they are found, has long been a mystery.

One group of researchers claim to have the answer. They have found evidence that these stone circles were erected with cosmic influences: that is, they were placed specifically to better see the Sun, the Moon and the stars.

But this may not be the whole story.

Stenness and Callanish were built some 5,000 years ago during the Neolithic period, more commonly known as the Stone Age. This was a time when communities had already settled into a farming lifestyle.

Thom proposed that standing stones served as observatories: places to best watch the stars

Soon after, Neolithic farmers started to create places to commemorate the dead. Stone circles were one way to do so.

The idea that these memorials were erected using astronomy is not new.

An academic called Alexander Thom spent several decades studying Britain's standing stones, starting in the 1930s. Due to their geometric accuracy, and despite the fact that the stones were made up of various shapes, Thom proposed that standing stones served as observatories: places to best watch the stars. He published his findings in 1955, about 30 years after he began his initial investigations.

Now, over half a century later, researchers have returned to the idea in a new study, published in the Journal of Archaeological Science: Reports in August 2016. The paper develops Thom's purported astronomical link further, and re-evaluates how and why Scotland's standing stones were built.

The researchers first looked at the way standing stones were aligned to astronomical events. They then combined this with data on the shape of the landscape and elevation of the ground.

It showed that their understanding of the Universe was that it was cyclic and made up of opposites

"We discovered there were only two different-shaped horizons surrounding these monuments, which was pretty incredible in itself, and that the Sun and the Moon were placed in very specific patterns in this landscape," says lead author Gail Higginbottom of the University of Adelaide, Australia. "These patterns were repeated across all these monuments. That was quite astounding."

Higginbottom concludes that the landscapes on which the stones were set were specifically chosen to show the most extreme rising and setting points of the Sun and Moon. Even if the landscape was mainly flat, people still looked for mountains or hills so they could see the most interesting Sun or Moon movements.

Further, Stenness and Callanish are believed to be the oldest reliably-dated circles where this occurred. Others followed suit well into the Bronze Age.

In all, Higginbottom's team applied their astronomical formula to more than 100 of Scotland's stone circles, finding similar patterns to the sky in each. "So it seems the tradition – that perhaps these two standing stone circles began – continued [for 2,000 years]," she says.

There's nothing we can see in prehistoric people in other walks of life that suggests they had this highly mathematical view of the world

Although there is no way to know exactly why these stone circles were created, Higginbottom believes it was so people could acknowledge the very places that showed the "permanent representation of their understanding of their universe."

That is, they understood the specific cycles of the Sun and Moon, which in turn connected them to nature. "It showed that their understanding of the Universe was that it was cyclic and made up of opposites," she says. "Dark and light, north and south, night and day."

However, this idea has plenty of detractors.

An element of astronomical activity may have influenced some stone circles, concedes Kenneth Brophy of the University of Glasgow in Scotland. But he says we cannot use current applications of science and maths to understand these individuals' motives.

"That's a very modern way of looking at the world," says Brophy. "We have to understand them through power structures in society, rather than emphasising arcane mathematical measurements. There's nothing we can see in prehistoric people in other walks of life that suggests they had this highly mathematical view of the world."

They're essentially very large houses for the dead and spirits

For Brophy, the circles represented ritual and power. Specific landscapes would have been chosen because they had a special history that people were drawn to. For instance, research has suggested that Callanish was built so that people could view one stone circle from another "in a very stage-managed way," he says.

The stones themselves are also revealing. Callanish was built out of stones with beautiful ripples and patterns, showing Earth's striking properties. "People weren't looking at the sky," says Brophy. "They were trying to capture the land."

It is also clear that stone circles were places where social rituals could have taken place, especially to honour the dead. There is evidence of burials and cremations at some sites, most notably at Stonehenge.

Gordon Noble of the University of Aberdeen specialises in Neolithic archaeology. He says that the ground plans of many of Scotland's stone circles are similar to the structures people built for their everyday housing. But instead of being for the living, the stone circles seem to have served the dead. "They're essentially very large houses for the dead and spirits," he says.

Death, it seems, had a strong grip on these Neolithic pagans.

"The dead probably continued to influence the everyday life," says Noble. He says the people may even have spent more time on structures for the dead than for their own settlements.

While some of the sites do appear to have astronomical alignments, such as the recumbent stone circles of north-east Scotland, Noble agrees with Brophy: astronomy alone does not explain how they were made. "If you [were] going to build something that marks [a] particular lunar cycle, I don't think you would put up stones of that scale," he says. "It's unnecessary."

It might even be that the stones became symbolic of the dead themselves

Instead, Noble argues that the circles were as much about ritual as showing off status. Communities could "out-do" each other by building bigger and bigger monuments, which expressed their power.

Regardless of how or why they were built, they were clearly sacred to the people who made them.

"People were living on more of an edge than we are in the western world," says Higginbottom. "There was still a sympathetic magic. They believed that if they set up these monuments, they [were] connecting death and [nature]."

It might even be that the stones became symbolic of the dead themselves. Their physical bodies were gone, but the stones represented the "watchers of this great spectacular sky show and of the seasons," Higginbottom says.

This story is a part of BBC Britain – a series focused on exploring this extraordinary island, one story at a time. Readers outside of the UK can see every BBC Britain story by heading to the Britain homepage; you also can see our latest stories by following us on Facebook and Twitter.