From Test of Emunah (#557) by Rabbi Avigdor Miller
When you come in the morning on the way to the beis haknesses (synagogue) to pray, and you see a smashed up car leaning against a lamppost, you know that last night somebody was carted off to the hospital, maybe to the morgue. It wasn’t a miracle, he transgressed the laws of nature and therefore he was punished on the spot. Most people receive on-the-spot punishment for transgressing the laws of nature.
Now the question arises: what did Hashem intend by this system? When people transgress the laws of Hashem, the laws of the Torah, the laws of righteousness, the punishment doesn’t come immediately. In most cases, people don’t even realize that they ever are punished. Whenever it does come, they don’t know why they’re being punished; they think it’s for nothing. But when it comes to the laws of nature, which also come from the Creator, they’re punished immediately. Why did Hashem make such a system?
If a man sees trouble coming, he should look into his deeds
So we see two principles here. First we see the principal that Hashem does not want people to be aware that there is punishment for sins. That’s why He postpones the punishment, to deceive them. Secondly we see that Hashem wants people to be aware that for transgressing the laws of nature there is punishment. And that’s why He makes the punishment come immediately. (…)
Im roah adam sheyesurim ba’im alav, if a man sees that adversity is coming upon him, man has a headache, toothache, an ulcer, heart trouble — chas v’shalom the list is very long. If a man sees trouble coming, yifashfeish b’maasav, he should look into his deeds (GEMARA). Now he can say, why should I look at my deeds? If Hashem punishes for physical negligence immediately, it was my fault. Had I taken care of my health this wouldn’t have happened. That’s what a sensible man would say, but he’s too sensible. He’s expected to understand that while this rule is true, at the same time is expected to look into his past and see if there’s something that caused this to take effect.