This line of questioning is closely related to spiritual discussions such as "How could God let this happen?" I don't know if you are religious or not, but I am, and that in turn drives my thought process. I can't separate my religious beliefs and my thoughts on anxiety as both deeply are a part of me. So if you get offended about topics that are religious in nature you might want to stop reading now, although I encourage you to continue because I think I have found some interesting stuff.
So- back to the "Why do bad things happen to good people?" question. I found a really cool quote that explains it much better than I could:
"Now, we find many people critical when a righteous person is killed, a young father or mother is taken from their family, or when violent deaths occur. [my own insert... or when we struggle with daily pain and suffering of anxiety, panic, and or depression.] Some become bitter when oft-repeated prayers seem unanswered. Some lose faith and turn sour when solemn administrations by holy men seem to be ignored and no restoration comes from repeated prayer circles. But if all the sick were healed, if all the righteous were protected and the wicked destroyed, the whole program of the Father would be annulled and the basic principle of the gospel, free agency, would be ended.
If pain and sorrow and total punishment immediately followed the doing of evil, no soul would repeat a misdeed. If joy and peace and rewards were instantaneously given the doer of good, there could be no evil- all would do good and not because of the rightness of doing good. There would be no test of strength, no development of character, no growth of powers, no free agency, no Satanic controls. Should all prayers be immediately answered according to our selfish desires and our limited understanding, then there would be little or no suffering, sorrow, or disappointment, or even death; and if these were not, there would also be an absence of joy, success, resurrection, eternal life, and godhood."
-Spencer W. Kimball
It makes sense doesn't it? There has to be opposition in all things. How can we know and understand joy if we never feel pain? How can we appreciate the good days without the bad? How can we enjoy life if there were no death?