Opium used to be THE drug that everyone took in the Victorian era, at least, as far as I can tell. Yet, nowadays, it's fallen into obscurity. What caused this shift?
Short answer is that opium has been phased out due to the creation of modern alternatives, development of medicine and legal limitation of the drug accessibility. Now for the longer answer.
Opium, that is, a poppy milk derivative. whether as a fresh liquid or in its more dense, evaporated state, has been a mainstay of common European medicine for millennia. It has been mentioned in the Ebers papyrus dated to 25th century BCE, where it is presented in a medical dialogue between Horus and Thoth. The problem in question is a debilitating headache in 'forehead and right temple', what might be interpreted as a cluster migraine pain. After a magical practice of putting the fish skull against an head proves unsuccesful, an ingestion of fresh poppy milk is proposed, what leads to the remission of the symptoms. Included in the pharmacopeias by ancient Greek scholars, it became a common ingredient in various tinctures and theriacs throughout Antiquity, Middle Ages and well into the modern era.
It is worth noting that if we consider morphine a more refined form of opium, the we can safely say that the latter is still widely used, although its usage has been limited to the areas whee opiates are effective, i.e. to alleviate serious pain, usually in highly controlled environment that allows precise dosage. This is why cheap and well known morphine is quite common in hospital settings, especially whenever cheap, potent and easy to produce analgesic is required.
Now, it is important to remember that prior to mid-19th century, European medicine was relatively poorly developed and the mechanisms of the human body were hardly understood. It does not mean that physicians did not have any successful treatments in their repertoire, but these were most often than not a result of hit-and-miss application of various methods that could have proven effective at times. This stands in stark contrast with surgery that, being a very practical form of intervention, was developed quite well with the potential infections being much more of a problem than the surgical procedures that were quite advanced in Ancient Greek practice and became more and more refined during the medieval and early modern period.
Thus, with the etiology of the illness being not well understood, an increase in patient's well-being was generally considered a proof of remission of the condition itself. Thus, with pain, fatigue and associated distress being very common symptoms of most health problems, an effective analgesic and relaxant could have been easily construed as an effective treatment. And if there is one thing that opiates do well, it is alleviation of the pain and muscle relaxation. Until, of course, addiction and withdrawal sets in. Think of any situation where we take any sort of analgesic, most commonly acetaminophen (Tylenol, Panadol), ibuprofen or ketoprofen and note that before 20th century, people in such situation were usually resorting to opium-based remedies. As you can probably imagine, this heavily contributed to the popularity of the substance, especially given the percentage of people who were performing menial tasks.
It is interesting that although detrimental effects of opiates have been known for centuries, its usage was generally justified as the pain and associated problems were considered much worse alternative to a potential side effects of opium ingestion. This is evident in the case of 25th Earl of Mar who died in 1828, having previously bought a life insurance. The financial company who issued the latter objected to paying the agreed sum after the discovery that the aristocrat has been a habitual opium user, who has been taking almost 50 grains of opium daily and thus willingly and artificially shortened his life. The company won the case in the first hearing, but then lost the appeal. Legal representatives of the late aristocrat argued that their client, who passed away at 65 (nowhere close to an 'untimely death' at a time) has been consuming opium since his early adulthood and for many years he was forced to do so because of the debilitating gout, thus opium only made his life more bearable. In addition, Earl has been said to die of 'jaundice and dropsy' meaning that his skin and corneas had a yellowish hue and the body shown significant oedema. Both symptoms strongly suggest liver and kidney failure consistent with potential results of an untreated, progressive gout.
Opium has also been used by parents to pacify small kids, especially during teething. In 19th century, one of the most popular patent medicines of that type was Godfrey's Cordial produced in the second half of 18th century by an unknown apothecary. Its formula has been reverse-engineered by Thomas Wakley in 1823 and according to this analysis, it was an alcohol-based tincture containing unspecified theriac, sassafrass oil, ginger and opium (0.25% by mass). Thus, it definitely had some antimicrobial properties due to presence of safrol, eugenol and zingiberene, and an substantial analgesic effect.
There is also one more important side of the popularity of opium. besides strong analgesic and narcotic properties, alkaloids present in the poppy milk, chiefly codeine and noscapine have strong antitussive (cough suppressing) properties and similarly to many stimulants, it also suppresses feeling of hunger. The former characteristics made opium and later opiates a sought medicine for people suffering from tuberculosis that was very common in 18th and 19th century Europe, especially in the colder climates. Some authors also indicate that the hunger suppression made it attractive for the poorer people, especially from working classes, who were using it to alleviate both chronic pain resulting from daily physical strain or deteriorating health, and hunger caused by relative poverty.
The steadily increasing rate of the medicine development in the second half of 19th century also coincided with the growing concern of the opium's side-effects. These changes were initially opposed by the chemists, such as those in England, who lobbied against the passing of 1857 bill classifying opium, products using it as an ingredient and other poppy milk derivatives as poisons. The first restrictions were introduced in Pharmacy Act of 1868, but it only limited the sale of opium derivatives to chemists and apothecarians and did not address the 'patent medicines' often containing opium as one of the main ingredients. Early 20th century brought rapid limitations in the trade of many potent medicines, e.g. British Pharmacy Act of 1908 classified opium as a dangerous poison. This was shortly followed by an international pressure to limit the access to opiates, especially in everyday use and usage in child treatment that resulted in the International Opium Convention signed in Hague on 23rd January 1912, entering into force in 1919 and ratified by various countries between 1912 and 1946. This agreement called for the restriction and strict reglamentation of production, sales, import and export of opium, heroine, cocaine and medicines using these substances as ingredients (including derivatives yet unknown that would have share potency and side effects with mentioned substances). In also suggested introduction of penalties for illegal possession of such drugs (Article 20).
So, to sum it up, opium, although ubiquitous until mid-19th century, has been slowly displaced by other, more purified forms of the the basic material, first heroine, then morphine and then synthetic opiates and their successors. In addition, better understanding of medicine allowed doctors to differentiate between axial and side symptoms and thus analgesic effect was no longer equated with therapeutic one, what also propelled the research of various analgesics that had similar effect on light and moderate pain, with much less pronounced side effects. Better understanding of the human body also made it possible to develop medicines that actually helped rather than made patient only feel better.