Opium, the mother of pain relief medications, has a long history as a treatment drug. It was used in such ancient countries as Sumer, Assyria, Greece, Egypt, China, India, Persia, and others. Such famous ancient physicians as Hippocrates and Galen also prescribed it to treat several illnesses. Besides, ancient people were aware of its ability to provide euphoria.
For those interested in a more recent history, AddictionResource authors created this infographic. Opium is used for the same purposes these days. But the consumption of crude opium declined in the 20th century. People started to derive different substances from opium poppies. Many of them are prescribed for a wide range of medical needs. Some people also use the drug illegally, to get high. But the market is flooded by newer types of drugs.
Infographic Source: https://addictionresource.com/drugs/opium/