“To the divine providence it has seemed good to prepare in the world to come for the righteous good things, which the unrighteous shall not enjoy; and for the wicked evil things, by which the good shall not be tormented. But as for the good things of this life, and its ills, God has willed that these should be common to both; that we might not too eagerly covet the things which wicked men are seen equally to enjoy, nor shrink with an unseemly fear from the ills which even good men often suffer.”
St. Augustine of Hippo in The City of God
This is perhaps a partial answer to the question of why bad things happen to good people. I am reminded of Jesus’ words,
“He causes His sun to rise on the evil and the good, and sends rain on the righteous and the unrighteous” (Matt 5:45).
What strikes me about this is that I should not be so quick to complain when things don’t go the way I think they ought to go. God has a bigger plan and is working all things out according to that plan.