I've been reading Dreamland by Sam Quinones, which goes into detail and background of the past ~50 years or so about how we got into this situation. A large part of the WHY you're referring to I'll summarize as
1. Pain being identified as a vital sign and hospitals/institutions new-found focus on tracking and treating pain
2. Deceptive pharmaceutical marketing that painkillers are a be-all solution to pain and also non-addictive (Purdue/Sackler seem to be worst offenders here)
This lead to doctors prescribing opioid painkillers to many of middle-class americans who would likely have otherwise not come in contact with drug addiction. The book so far has been a really good read and also goes into detail around how heroin started spreading through the rust belt as well (feeding on the existing prescription addiction). I highly recommend it (about 65% through it right now).