In the latter half of the 19th Century, especially in the late 1890s did our predecessors use these products to calm themselves down or help the little kiddies get over their nagging little toothaches and sleep better at night time.
Obviously before Bayer invented Aspirin (from coal tar) they specialised in more exotic drugs.
Cocaine was originally added to Coca Cola as a pick me up but discontinued fairly quickly.
Cocaine was also used for toothache and other problems that resulted from surgery and medical treatment.
It quickly became a substance of reliance and then of abuse.