When confronted with this question, Jesus turned it around …
There were present at that season some who told Him about the Galileans whose blood Pilate had mingled with their sacrifices.
And Jesus answered and said to them, “Do you suppose that these Galileans were worse sinners than all other Galileans, because they suffered such things?
I tell you, no; but unless you repent you will all likewise perish.
Or those eighteen on whom the tower in Siloam fell and killed them, do you think that they were worse sinners than all other men who dwelt in Jerusalem?
I tell you, no; but unless you repent you will all likewise perish.”
… in essence, the question is not about why bad things happen to good people, instead it is why should good things happen to bad people? The thing is, we have all sinned and we are all deserving of worse happenening to us. Our only hope is to repent of our sin and turn to Jesus for salvation.