Ways God Works...
To help answer our question "Why do bad things happen to good people?", it's important to understand how God conducts his business. In your limited acquaintance with God, you may have already observed that He works in two basic ways:
God "Allows" Things To Happen...
Because of "Our Agency", we are allowed to succeed or fail, based on our choices. Sometimes we succeed and fail in quite dramatic ways. Because of "Other's Agency", they are allowed to affect our lives and inflict pain and misery on innocent people. No one, especially the wicked, can be judged unless they are allowed to exercise their agency and carry out the ill will that's in their hearts. God will never interfere with our agency, nor theirs. However...
While one may think their own agency is restricted or lost based on the wicked actions of others, it is part of the Plan of Happiness to suffer through these trials. We knew beforehand this kind of treatment could happen. We knew the results it would produce. Through our suffering, we grow. The more we suffer, the greater our growth. It's one of the mysteries of life that require a great deal of faith. That's because most of what we learn here, won't be manifest until the next life, when an accounting of our lives is made. The most significant part of the Atonement of Christ is, all the damage that is done to us here will be more than compensated for in the Eternities.
A major part of our test is found in what we do and how we react to what is allowed to happen to us.
God "Causes" Things To Happen...
God causes the Earth to turn, the sun to rise, the rains to fall. He orchestrates everything for our best good, including extensive opportunities in every aspect of our lives. Most of us are blessed with good health, great wealth, fantastic friends, family, neighbors and work associates; flourishing economies, thick rich soil, jewel laden mines and everything you could imagine that can provide prosperity. Yet, some of us are denied those things to one degree or another as part of our test.
Not only do we suffer at the hands of others, in our learning experiences, the earth has been ordained to produce tumultuous activities for us to learn from and deal with. In those instances, we are always encouraged to call on God for deliverance from the elements, famines, pestilence, draught and disease, etc. But, we don't always avail ourselves of that blessing. That's another reason "bad things happen to good people!" We don't call on God.
God can alter the length of a day, temper the elements, expedite the mail, enlighten your mind and lead you to wonderful opportunities. He can do anything, if it will help you successfully return to live with him. But, you are still free to work, move about and think for yourself; free to "act on" or "react to" each situation you face. Still, it all happens according to His will concerning your best good.