Half the story is missing -- who is paying for those pills? Insurance coverage? Individuals paying cash (and suspected of reselling, or fueling personal addictions?) Are individual patients' prescriptions for two many pills? Or too many patients getting prescriptions compared to averages in other cities/states?
Many "pill mills" are essentially drug-dealing operations using a doctor and a pharmacy (who get a cut of the profit) to obtain huge quantities of opioids which are then sold on demand, cash-only basis, to anyone who wants them.
In some cases the doctor gets paid to just sign a big stack of blank prescription slips to be filled in later. In other cases the doctor is paid to "prescribe" for anyone who comes in and complains of pain.
Also note that quite a lot of the problem is blamed on pharmaceutical companies allegedly misrepresenting the effectiveness of "extended-release" formulations of their drugs, leading patients to take larger doses and become dependent. Purdue has plead guilty to misleading the public about the risk of dependence with OxyContin, for example.
And for a more in-depth look at the origins check out Frontline's "Chasing Heroin" [2]
[1] https://youtu.be/jrE1uxGd6OQ
[2] http://www.pbs.org/wgbh/frontline/announcement/chasing-heroi...