There are several reasons. Miss Dubose serves to illustrate the public reaction (already foreshadowed by Francis's talk over Christmas of Atticus being a disgrace to the family because of his part in defending Tom Robinson) to Atticus's involvement in the trial. Scout did her best to remain calm, but this illustrates Jem's breaking point.
Another reason for introducing Miss Dubose is to illustrate Atticus's constant theme of crawling into someone's skin to see what the world looks like through their eyes. After Atticus informs Jem that his reading was just to ease her withdrawals from morphine addiction (and remember Atticus would have had Jem read to her anyway, regardless of what he did to her flowers), Jem is able to see another side of the seemingly terrible and monstrous old lady.
Her posthumous gift to Jem reveals a much different side to Miss Dubose than Jem ever would have realized. This is key for the children because as Atticus told Jack over Christmas, he doesn't want the children to become bitter over the trial. One key to not being bitter is to realize that people are not always what they seem. Miss Dubose wasn't just a mean spirited old lady. Once one looked at things from her vantage point, one realizes that she is quite different. Atticus even reveals that she was the bravest person her ever knew.
Miss Dubose is in the story to demonstrate the theme that real courage is fighting even if one knows the battle is impossible or highly improbable to win. She is dying but is determined to break her addiction to the pain killer that was given to her as a treatment for the pain the disease caused. She didn't want to die with something she considered a sign of weakness. This is the same sort of courage it took for Atticus to take on the Tom Robinson case. He knew it was a case he couldn't win with a jury in Maycomb, but he gave it his best shot. He fought knowing he'd lose in the end, just as Miss Dubose fought her addiction knowing she'd die anyway.
i dont really know except that she shows jem and scout that courage is more than shooting a gun.
Although Miss Dubose has many importants roles in the book. I believe the most important reason is how how Lee helps Miss Dubose show the reader the change in maturity of Jem Finch. Lee does this by having Jem throw the candy box into the fire but keep the flower as a symbol of forgiveness. He shows how he is matured, if this had happened in the beginning of the story Jem most likely would have thrown both the candy box and the flower into the fire. He did not because he finally began to understand Miss Dubose as he took his father's advice and "stepped into her shoes" when he read to her.