You don’t necessarily get punished because you are bad. Ask Job.
It all balances out. When God lets bad things happen to good people, He compensates by having good things happen to bad people.