Bad things can happen to anybody whether to good people or bad people, because we live in a world where people doesn't care about each other. Since the time of Adam and Eve, sin has affected all of creation, bringing pain, suffering, and injustice into human life. Even those who try to live righteously are not completely shielded from these effects, because the world itself is not yet perfect.
Sometimes God allows trials in our life so as to shape our faith draw us close to him again. The Bible shows that God can use difficult situations to build patience, strengthen trust, and draw people closer to Him. For example, the story of Job shows a righteous man who suffered greatly, yet remained faithful, and in the end, his faith was proven and rewarded.
The bible teaches us that God have a good and greater purpose for our future. What we may see that is unfair to happen to us, God wants to use it to show us something ahead in the future. Believers are encouraged to trust in God’s wisdom and remain faithful, knowing that He is just and will ultimately bring restoration and justice in His perfect time.