The short answer is, because there is no such thing as a good person. Let me explain.
A good illustration of bad things happening to good people was the nation of Israel. They were the chosen nation. God gave them a gazillion promises of blessings in every area of their lives. And yet there was hardly a generation in Israel that enjoyed all those blessings. Why? Because they kept walking away from God, kept trying to be like the other nations, kept falling for other gods, were cruel to each other. Just because a person goes to church and looks holier than others doesn’t mean they are sinless. God has to keep sending good people bad things to correct them.
Just because you become a Christian, won’t make you automatically rich and healthy. In fact, the opposite may be occuring, because God is working on you.
Just like we need physical exercise to stay healthy, so do we need spiritual exercise. If you just lay in bed every day, pretty soon, your body will start to deteriorate. We need to get up and move to stay healthy. A guy who goes to work out at a gym knows that the process of growing muscles is not pleasant. And yet he still goes there, because he knows that the pain he experiences makes his muscles bigger. Same thing happens in the spiritual world. If we never have any troubles, we will become warm Christians, spiritually deteriorate, and eventually die spiritually.