The problem is complicated. Here are some abridged points from an OECD document linked below.

1. Overprescription, in the US, there were 240 million opioid prescriptions in the US in 2015, enough for one for every adult in the general population.[1]

2. Poor mental health treatment, "in the United States, 18.7% of all patients with mental health conditions receive 51.4% of the total opioid prescriptions distributed each year, meaning that having a mental health disorder was associated with a two-fold greater use of prescription opioids"[1]

3. Greater availability + lower cost and higher purity of opioids sold by criminal orsg. Mexican criminal orgs have been pushing much greater amounts of opioids in the last ten years, probably due to profits from marijuana being undercut. Prescription drug OD deaths have actually decreased as people switch from controlled substances to heroin/other opiates.[2]

4. Lack of access to effective treatment procedures. The US is woefully inadequate in this regard. "n the United States and Canada, rehabilitation programmes are still mainly abstinence based (Annan et al., 2017[75]). More specifically, in the United States only 8-9% of all substance treatment facilities between 2006 and 2016 had MAT programmes certified by SAMHSA...This happens despite evidence showing that opioid users who are treated only with psychological support are at twice greater overdose death risk than those who receive opioid agonist pharmacotherapy (Pierce et al., 2016[77])"

5. Stigmatization causing addicts not to seek treatment. "Research indicates that stigma contributes to individuals poor mental and physical health, non‐completion of substance use treatment, delayed recovery and reintegration processes, and increased involvement in risky behaviour (e.g. needle sharing)"

OxyContin is a controlled substance, so it's not actually legal. Here is an excerpt from an OECD publication on the opioid crisis on a specific case of decriminalization of opioids:

In 2001, Portugal decriminalised the possession and consumption of all narcotics and psychotropic substances for personal use, intended as the quantity required for an average individual consumption during a period of ten days. Exceeding this quantity, criminal procedures apply. Portugal’s decriminalisation reform has been particularly influential, since by introducing a de jure decriminalisation (changes in the law instead of changes in the daily practice), it has been a pioneer of the explicit decriminalisation of all drugs. Some of the main benefits of decriminalisation mentioned by Portuguese authorities can be summarised as follows:

Changes in the mind-set of the general population, contributing to consider drug use disorders as a medical condition rather than a criminal offence.

Creation of supplementary entrance doors to the public health system, particularly, through the Commissions for the Dissuasion of Drug Dependence.

Coherence enhancement between the health and judicial systems, markedly, to provide and expand access to public health interventions.

...

The decriminalisation of drugs is controversial in nature. However, empirical evidence shows that following decriminalization, Portugal has not witnessed major increases in drug use, but has experienced reductions in problematic use, drug-related harms (e.g. HIV-AIDS, hepatitis, overdose deaths) and criminal justice overcrowding (EMCDDA, 2018[223]; Hughes and Stevens, 2010[224]; Greenwald, 2009[225]). In addition, decriminalisation seems to have caused no harm through lower illicit drugs prices, which would lead to higher drug usage and dependence (Félix and Portugal, 2017[226]).[1]

I recommend checking out the sources I've linked, there's a lot of interesting information in them.

1. https://www.oecd-ilibrary.org/social-issues-migration-health...

2. https://www.overdosefreepa.pitt.edu/wp-content/uploads/2017/...