In my own spiritual journey one of the things I have struggled with the most is this idea of God's punishment. The extremists look at everything bad and see it as punishment from God. I can still remember when my brother was killed someone asked my mother, "Do you think if you had taken church more this would have happened?" It not only made me angry but I thought it was the stupidest idea in the world. I of course swung to the other extreme, God is a loving God doesn't go around punishing people. I was 12.
It took me a very long time to realize that ,like in most things, the truth was somewhere in the middle. Is every bad thing that happens a punishment from God? No. Are some bad things that happen punishment from God? Yes. And as the prophet Amos explains, God punishes because he loves us.
You alone have I favored, more than all the families of the earth;Therefore I will punish you for all your crimes.
What is the purpose of the punishment? Conversion. God does it in order to encourage us to change. If God is love then not only does God punish, God must punish. Is there a decent parent alive who does not punish their children.
The problem for us that we cannot always tell clearly when some bad thing is the result of someone else acting sinfully or maliciously and when it is punishment for something we have done. And we may never in this life know for certain about some things.
Our response should be two-fold. Firstly, we must never doubt God's love. Even when we commit mortal sin God still loves us. Secondly, we should regularly examine our conscience. The scriptures are clear that God does not punish every time some commits a sin, God alone steps in and punishes when there is hardness of heart, when people sin and the stubbornly persist in it.
When we sin, instead of digging our heels in like a petulant child, we should have the courage to own up to our sin, do our penance, and make a real effort to change. Then we never have to worry about God's punishment.