It’s a rich dark liquid that flows across the world and greases the wheels of our economies. It’s one of the most traded commodities. And there are fears that, with a seemingly irrepressible demand, we may one day run dry.

No, I’m not talking about oil, but coffee. More than two billion “cups of joe” are drunk every day and for many, working life would feel impossible without it. As traditionally tea-drinking countries like China are seduced by coffee’s charms, it may soon become the world’s favourite drink.

What is driving this insatiable thirst, and how has the beverage come to conquer the world? Is it the abrasive but aromatic flavours, its psychoactive effects or its social currency? And how can its farmers overcome the challenges created by human-made climate change?

Coffee’s story starts in the lush highlands of Ethiopia, the natural homeland of the delicate Coffea arabica plant. Although they are called “coffee beans”, the plant is not a legume, and the fruits of the coffee tree look more like cherries when they are first picked. The seeds inside are extracted and dried before the process of roasting turns them into the hard, nutty nodules we feed into our grinders.

The Oromo people from this region are thought to have been the first to have noticed the stimulating effects of these “beans”, and coffee still remains an important element of their traditional cuisine. Exactly how and when it spread beyond Ethiopia is still the subject of many legends, but the available historic records suggest that the Sufis of Yemen were the first truly devoted drinkers outside Africa in the Middle Ages – where it was intimately connected with their mystic rituals.

“Never was a religious ceremony performed without coffee being drunk,” writes the food writer and cultural anthropologist Claudia Roden. Its caffeine helped them to continue their practices late into the night, while the roasting of the bean was apparently taken as an analogy for the transcendence of the human soul.

Coffee houses soon spread across the Middle East and the Ottoman Empire, where they caught the attention of Western traders, who took the beguiling drink back to their home countries in the 17th Century. The early drinkers were firm believers in its medicinal properties. Roden quotes one newspaper advert in 1657 that described the drink as “having many excellent virtues, closes the orifice of the stomack, fortifies the heart within, helpeth dijestion, quickneth the spirits…”

These observations have been born out by recent studies, which suggest that coffee can offer some protection from certain common diseases. A recent review of the evidence by Susanna Larsson at the Karolinska Institute in Sweden found that each cup of coffee per day is associated with a 6% reduction in the risk of type 2 diabetes. Laura Van Dongen at Wageningen University in the Netherlands, meanwhile, has found that regular coffee drinkers were at least 20% less likely to die from heart disease.

Besides providing this reportedly life-enhancing drink, the early European coffee houses also became popular meeting places for businessmen – and some even birthed the financial institutions we still turn to today. The insurance company Lloyds of London, for instance, emerged from the Lloyds Coffee Shop in the 18th Century, where sailors and merchants would meet to discuss their affairs.

European settlers would also come to introduce the plant to their colonies in Asia and South America: Portugal brought coffee to Brazil, France to Vietnam, and Spain to Colombia. The sale of coffee was intimately linked with the slave trade, which was not abolished until the 1850s in Colombia and the 1880s in Brazil.

Coffee still remains vital for these countries’ economies, and Brazil, Vietnam and Colombia are today the three biggest producers of the raw coffee bean, while the United States, Germany and France are the biggest importers.