Does God punish you for bad behavior?
Why do bad things happen to people? Sometimes it’s simply due to chance (Eccl. 9:11). Sometimes it’s because God allows Satan to bring bad things into our lives to test our faith (Job 1-2).
Sometimes God out of love allows bad things to happen to us in order to discipline us (Heb. 12:3-11). This helps make us spiritually stronger (vs. 9-11). It could also be His way to punish us for wrongdoing (cf. 1 Cor. 11:29-32).
Without divine revelation (of which no more is forthcoming – Jude 3), we simply don’t know God’s reasons in a particular case. Therefore, we shouldn’t assume anything like Job’s friends did (cf. John 7:24).