Halloween is a time when ghosts and spooky decorations are on public display, reminding us of the realm of the dead. But could they also be instructing us in important lessons on how to lead moral lives?

The origins of modern-day Halloween date back to ‘samhain’, a Celtic celebration for the beginning of the dark half of the year when, it was widely believed, the realm between the living and the dead overlapped and ghosts could be commonly encountered.

In 601 AD, to help his drive to convert northern Europe to Christianity, Pope Gregory I directed missionaries not to stop pagan celebrations, but rather to Christianise them.

You might also like:
• The truth about the paranormal
• The camera tricks that can summon ghosts
• Why science says you need a nap

Accordingly, over time, the celebrations of samhain became All Souls’ Day and All Saint’s Day, when speaking with the dead was considered religiously appropriate. All Saint’s Day was also known as All Hallows’ Day and the night before became All Hallows’ Evening, or ‘Hallowe’en’.

Not only did the pagan beliefs around spirits of the dead continue, but they also became part of many of early church practices.

Lucrative belief

Pope Gregory I himself suggested that people seeing ghosts should say masses for them. The dead, in this view, might require help from the living to make their journey towards Heaven.

During the Middle Ages, beliefs about souls trapped in purgatory led to the church’s increasing practice of selling indulgences – payments to the church to reduce penalties for sins. The widespread belief in ghosts turned the sale of indulgences into a lucrative practice for the church.

It was such beliefs that contributed to the Reformation, the division of Christianity into Protestantism and Catholicism led by German theologian Martin Luther. Indeed, Luther’s 95 Theses, nailed to the All Saints Church in Wittenburg on 31 October 1517, was largely a protest against the selling of indulgences.

Subsequently, ghosts became identified with ‘Catholic superstitions’ in Protestant countries.

Debates, however, continued about the existence of ghosts and people increasingly turned to science to deal with the issue. By the 19th Century, Spiritualism, a new movement which claimed that the dead could converse with the living, was fast becoming mainstream, and featured popular techniques such as seances, the ouija board, spirit photography and the like.

Although Spiritualism faded in cultural importance after World War One, many of its approaches can be seen in the ‘ghost hunters’ of today, who often seek to prove the existence of ghosts using scientific techniques.

In Taiwan, for example, about 90% of people report seeing ghosts

These beliefs are not just part of the Christian world. Most, although not all, societies have a concept of ‘ghosts’. In Taiwan, for example, about 90% of people report seeing ghosts.

Along with many Asian countries such as Japan, Korea, China and Vietnam, Taiwan celebrates a Ghost Month, which includes a central Ghost Day,  when ghosts are believed to freely roam the world of the living. These festivals and beliefs are often tied to the Buddhist story of the Urabon Sutra, where Buddha instructs a young priest on how to help his mother whom he sees suffering as a ‘hungry ghost’.

As in many traditions, Taiwanese ghosts are seen either as ‘friendly’ or ‘unfriendly’. The friendly ghosts are commonly ancestral or familial and are welcomed into the home during the ghost festival. The unfriendly ghosts are those that are angry or ‘hungry’ and haunt the living.

Moral reminder

As a mythology scholar at the University of Southern California who has studied and taught ghost stories for many years, I have found that ghosts generally ‘haunt’ for good reasons. These could range from unsolved murders, lack of proper funerals, forced suicides, preventable tragedies and other ethical failures.

Ghosts, in this light, are often seeking justice from beyond the grave. They could make such demands from individuals, or from societies as a whole. For example, in the US, sightings have been reported of African-American slaves and murdered Native Americans. Scholar Elizabeth Tucker, from Binghamton State University of New York, details many of these reported sightings on university campuses, often tied to sordid aspects of the campus’s past.

Sightings are often a reminder that ethical lapses can carry a heavy spiritual burden

In this way, ghosts reveal the shadow side of ethics. Their sightings are often a reminder that ethics and morality transcend our lives and that ethical lapses can carry a heavy spiritual burden.

Yet ghost stories are also hopeful. In suggesting a life after death, they offer a chance to be in contact with those that have passed and therefore a chance for redemption – a way to atone for past wrongs.

This Halloween, along with the shrieks and shtick, you may want to take a few minutes to appreciate the role of ghosts in our haunted pasts and how they guide us to lead moral and ethical lives.

This article originally appeared on The Conversation, and is republished under a Creative Commons licence. 

Join 900,000+ Future fans by liking us on Facebook, or follow us on Twitter or Instagram.

If you liked this story, sign up for the weekly bbc.com features newsletter, called “If You Only Read 6 Things This Week”. A handpicked selection of stories from BBC Future, Culture, Capital, and Travel, delivered to your inbox every Friday.