Most of us take modern restrooms for granted, but proper sanitation is a relatively modern phenomenon and is still far too rare in the poorest regions of the world.

The need to keep human and animal waste away from human contact may seem obvious today, but for millennia that was not the case. Before the emergence of the germ theory of disease, and the subsequent public health campaigns and construction of adequate sanitation infrastructure in most of the world, people and waste commingled – with catastrophic results.

Countless millions of people got sick or died from diseases such as diarrhoea, ascariasis (a type of intestinal worm infection), cholera, hepatitis, trachoma, polio, schistosomiasis and so on.

In due deference to our ancestors, it has to be noted that some cultures, such as ancient Rome, paid due attention to cleanliness. The Romans built numerous public baths, which were accessible even to the very poor for a nominal fee, and a sophisticated system of sewers that enabled Rome to grow and reach a population of over 1 million people around the start of the first millennium. That feat would not be replicated in Europe until London and Paris in the 19th century.

In general, however, standards of hygiene tended to be very poor. A typical urban dwelling had a cesspit underneath the house or next to it. That’s where human and kitchen waste accumulated and fermented. Inadequate drainage, irregular emptying and heavy rains could make the cesspit overflow and seep into the house. While discouraged by the city authorities, people often emptied their chamber pots into the streets below.

As Johan Norbeg of the Cato Institute wrote in his 2016 book Progress: Ten Reasons to Look Forward to the Future, “When pedestrians heard the shout of ‘Gardyloo!’ they ran for cover. This phrase, taken from the French for ‘Look out for the water,’ was your only warning that someone was about to throw their waste out of the window.”

In rural areas, people lived with their animals, including chickens and cows, and used both animal and human waste to fertilise their crops – an extremely dangerous practice compounded by the fact that people could go throughout much of their lives without ever washing their hands. That led to epidemics of disease as well as other unsavoury consequences.

The Jews, who sometimes died at lower rates than the rest of the populace thanks to the frequent washing of hands that is prescribed by Judaism, were often accused of witchcraft, persecuted and even killed.

The Black Death, which killed between 30 and 60 per cent of the European population in the 14th century, complicated matters further. According to some medical experts of the day, “once heat and water created openings (pores) through the skin, the plague could easily invade the entire body.” As such, even the rich and powerful tended to avoid bathing. Elizabeth I took a bath once a month, “whether she needed it or not,” but her successor, James I, only washed his fingers.

The Journal de la santé, which was kept for Louis XIV by his doctors from infancy until a few years before he died, described the king’s daily life in microscopic detail, but mentioned bathing only once. His magnificent palace of Versailles had no proper waste facilities and people relieved themselves where they stood – in the hallways, behind the curtains and in the gardens.

One 18th century observer noted that Versailles was “the receptacle of all of humanity’s horrors – the passageways, corridors and courtyards are filled with urine and faecal matter.” All that filth was an excellent breeding ground for vermin and disease that periodically decimated the rich and poor alike.

Today, poor sanitation is mostly limited to very poor countries. In sub-Saharan Africa, for example, a mere 30 percent of the population had access to improved sanitation facilities in 2015. That was an improvement on 1990, when only 24 percent did. In other parts of the world, progress was much faster.

In South Asia, which includes very populous countries like India and Bangladesh, the share of the population with access to improved sanitation rose from 20 to 45 percent over the same time period. Globally, it increased from 53 to 68 percent. That should only improve with Prime Minister Modi’s ‘Clean India’ project to build some 111 million new toilets in the space of just five years.

The United Nations’ aim of ending open defecation by 2030 seems quite optimistic for regions like sub-Saharan Africa and South Asia, but there is no apparent reason why East Asia, Latin America and the Middle East should not be able to reach the European level of 93 percent or even the North American level of 100 percent by 2030.

As in so many areas of human development, what was once the preserve of the rich West is now becoming commonplace all over the world, helping ever more people live richer, healthier, more hygienic lives.

This first appeared in CapX.