Someone asked this question in a Judaism & Christianity history class I am in, and I thought about a possible partial answer. Feel free to DM me if you disagree or have other thoughts about this post.
Firstly, are we misinterpreting "bad things"? Are bad things somehow good or a test, and we must dig deeper into the lessons? I believe not; the truth is bad things do happen to good people.
If we're forced to love something, we will never truly love it. That is why God gave humans free will. Because if we love God, that is a decision we need to make within ourselves, or else the relationship isn't meaningful.
So, humans can actively choose to follow God and create in His loving image or ignore it and create without it.
If God is love, accepting Him and creating in His loving image will create good things. If you ignore Him and create in your egotistical image, you will create self-centred, arguably "bad" things that don't truly benefit humanity in the best ways. They benefit you more than others. Someone has to be on the other side of this trade.
These self-centred things created without God in mind scale into complex human systems that affect many people. They even affect people outside these local systems. Hence, bad things happen to good people. Bad things happen to good people because some people choose not to act in the image of love but in their selfish interests.
If everyone loved God properly and acted in love and truth, even when it didn't benefit them materially, maybe bad things would not happen to good people because everything created would be love.