The problem is predicated on a lie, of course. Paul says, "No one does good, not even one" (Rom 3:12). The short answer to "Why do bad things happen to good people?" is "They don't." You see, there are no "good people". And the problem comes from the premise that God owes, in some sense or another, good things to His creation. God would be wrong to "be mean" to us. That is, there is some higher sense of "good and bad" to which God must align Himself if He is to be considered good. And that, of course, is the product of "I will be like the Most High." Not a good premise.
Still, I know a lot of people who have problems with the whole idea. Genuine believers, wrestling with the truth, loving God and feeling the pain of others, struggle over this. It can be something like the death of a child or a lost job. It can be something as monumental as the concept of Election. But the question still seems to be there, and it doesn't go away. And I understand that.
For some reason, it doesn't seem to bother me as much. As I said, the short answer is easy. There is no one who is good, so what was the question? But I have a much harder question to answer. The one we never seem to ask is this: "Why do good things happen to bad people?" Now that is a genuine puzzler. We know, for instance, that God brings rain on the just and the unjust. He doesn't have to. He's not obligated to. But He does. Why? We know that the wicked prosper. Why? And when we read how things really are, it gets downright baffling. According to Paul, it is God's intention to demonstrate His wrath and power on "vessels of wrath prepared for destruction". That would be all of us.
Paul uses the phrase when he faces the main objection to the doctrine of Election. He explains "Jacob I love, but Esau I hated" and tells his readers that it was "in order that God's purpose of election might continue, not because of works but because of Him who calls." "That's not fair!" is the first objection. So Paul tells us that "It depends not on human will or exertion, but on God, who has mercy." That's when he faces that final objection:
You will say to me then, "Why does he still find fault? For who can resist his will?" But who are you, O man, to answer back to God? Will what is molded say to its molder, "Why have you made me like this?" Has the potter no right over the clay, to make out of the same lump one vessel for honorable use and another for dishonorable use? What if God, desiring to show his wrath and to make known his power, has endured with much patience vessels of wrath prepared for destruction, in order to make known the riches of his glory for vessels of mercy, which he has prepared beforehand for glory (Rom 9:19-23).You see, the question is not, "Why would God allow bad things to happen to good people?" The question is not even, "Why would God allow so many to go to Hell?" The question is "Why would God allow even one to avoid destruction?"
Why do good things happen to bad people? I can't really answer that, except to say that they do and it shows the mercy and grace of God. Now that's a true puzzlement ... but a good one.