Why do bad things happen to good people? In a nutshell, free will.
The best definition of the Bible I've ever heard is that it is the story of a Creator that fell madly in love with creation. God loves us more than we can know, and created us to love him/her in return. If you don't believe me read the Song of Songs, where God is almost blushingly effusive in describing the depths of that love.
Love cannot exist without free will. Think about it. If we were just robots who were programmed to "love" each other the result might mimic love, but it would not be real love. Real love must be voluntary, which requires the lovers to have free will.
What does humanity having free will mean? Well, look around. It means murder, rape, theft, selfishness, greed, racism and all manner of sins. Because the world is fallen it means disease. Because the world is evil it means Auschwitz, the killing fields, environmental degradation war, etc. It means some pretty horrible stuff. Which is, tragically, the price that God and humans must pay for love.
It didn't have to be that way and it wasn't God's original intent for humanity (see Genesis for details) but it is the way it must be until Jesus comes again.