It's a classic question, one that most if not all of us have wondered at times. Lets think about it this way:
Assume there is a different world, one where only good things happen to good people and only bad things happen to bad people. What wold life in this world be like? The good live nearly perfect lives in peace and prosperity and the bad live in anguish and misery. Sounds like a fair world?
Not so. In such a world there wold be no or very little common understanding between these two groups. They both would despise the other and live in judgment and condemnation of the other. This would lead to more conflict which would actually increase pain and suffering in the world.
Now consider the current world, where plenty happens to both good and bad people. When something bad happens to a bad person, many write it off as poetic or righteous justice. However when something bad happens to a good person, many ask why. When a child gets cancer, what is the reaction of empathy: this should not happen. What does that reaction do? It motivates some to go out and actually try to fix it.
People change professions, start charities, raise awareness, directly intervene, and have a whole host of reactions. Through all the trial and error that inevitably happens, some progress actually gets made. This is key. It is the fact that the good suffer which serves as a vehicle for actually reducing overall pain and suffering in the world.
its hard for people to understand that they are just animals living on a planet where the variables can be very random. The balance in the world comes from decisions made by us.