It seems pretty clear that the morphine was prescibed to her when she needed it but she became addicted. This was quite common in the late 19th and early 20th centuries, and is still prevelent now with other painkillers. The morphine aside, her condition slowly killed her.
In the 1930s there were very few pain-killing drugs--no OxyContin, etc. Laudanum, a 10% mixure of opium and 1% morphine was often used; however, it is very bitter to the taste. Morphine itself was used by medics in the two World Wars for men severely wounded on the battlefield. Nowadays it is used by patients with severe back pain that nothing else can alleviate; however, it effects are serious and often deadly, as it is an opiate, and, as such it is addictive and detrimental to one's body.
Mrs. Dubose was put on morphine to alleviate her pain because she obviously has a terminal condition. One of the effects of this drug is the alteration of brain function; this effect causes Mrs. Dubose to be so vituperative about Atticus. Perhaps, knowing that death is imminent, Mrs. Dubose wishes to end her life in a genuine state, at least. Her doing so, prompts the statement by Atticus Finch that she is the bravest person he knows.
I do not believe that there is any way to know this for sure. It's not specifically said. You do not have to misuse morphine to become addicted -- the drug is just naturally addictive. So there is no way to know for sure.
Here's the actual quote that tells us as much as we know:
"Mrs. Dubose was a morphine addict," said Atticus. "She took it as a
pain-killer for years. The doctor put her on it. She'd have spent
the rest of her life on it and died without so much agony, but she was