People with chronic pain can get painkillers legally, via a prescription, so this is a non-issue.
What we're talking about is a case of someone becoming addicted to painkillers and continuing to use them AFTER the condition causing chronic pain has passed, using pain-killers to get high.
Stoping the use of painkillers can cause chronic pain.
Anyone who injests drugs does it to relieve pain. It might not be the kind of pain with which you're personally familiar -- an aching elbow, for instance -- but it is pain nonetheless.
The word "legally" is just the way you and society describe the method you've devised to dole out the collections of molecules that relieve pain. People in pain take drugs to relieve pain, whether the drugs are "legal" or not.