The idea behind most forms of drug treatment is to slowly wean addicts off of their dependence. Because it's done in a controlled setting, you reduce the risk of accidental overdose and the toxic effects from tainted drugs. Though it isn't always practical or advisable to wean addicts off of their drug of choice using the exact same substance. For example, with people addicted to opiates and opioids, we usually use methadone, but that treatment has a number of limitations. In fact, recent research has suggested that, at least when compared to methadone, heroin-assisted treatment (HAT) methods may have better results. (In related news, we now have a new favorite inappropriate acronym. Step aside, Pederasts Under Punitive Prosecution for Youth-Crimes.)
In one study, researchers found that opioid addicts treated with heroin improved in both health and social stabilization, reducing their drug use at levels superior to similar methadone treatment programs. Even more interestingly, after four weeks, there were no detectable intoxication effects -- subjects could have potentially been able to drive after dosing up. Nobody wanted to be the first to hand them the keys to the school bus or anything, but still, that's theoretically impressive.
Heroin-assisted treatment is already a thing in some parts of the world. In both England and Switzerland, doctors can dispense small amounts of heroin to patients if they haven't been successful with methadone programs. The main barrier to implementing this program everywhere is really nothing but mindset. We'd have to stop considering addiction a moral failing, stop applying any kind of inherent morality to the drugs themselves, and start treating it like a health issue.
So, uh, have fun with methadone forever, Americans.