All major religions preach some version of it; even those who believe in reincarnation do, in that "eternal damnation" may not be quite-eternal, but it could involve coming back to live as a cockroach and being stepped on an interminable number of times.
Why?
Nobody has ever proved that to be true, you know.
My hypothesis is different than most: Those in power realize that, for every single person, there comes a time when its all you have left as a threat.
You see, "life in prison" is a pretty-good threat for someone who's 20. That's a long time, isn't it? All your hopes and dreams become that of living in a cage. Or for that matter the threat of execution -- obviously, if you're 20, death right now is a pretty-serious threat.
But how about the man who is 80 and knows he has liver cancer? He's dead, for sure, and there's nothing he can do about it. "Life in prison" is a meaningless sentence for such a person, is it not, and even the death penalty means little to someone who knows they're effectively already dead and since we are all mortal this time arrives, at some point, for all.
Hmmmmm.... and while some people simply drop dread with no warning, most get some warning while they still have some effectiveness left. Its the age-old "hourglass full of sand" problem; for nearly all of us we do not know how much is in there as the top of it is covered with paint; it is only when the sand is almost-exhausted that we know it is about to occur. Some of us get seconds (or less) of warning but many get a couple of years or months -- and during some of it we're still more-or-less functional.
So what if you were an evil bastard and were concerned someone might kill you for what you've done but you also can compel them to "pay" for doing it criminally? You've got trouble, because the man walking around with known liver cancer no longer can be criminally sanctioned if he whacks you and you know, in your own mind, that you deserve it.
What do you do?
You invent a means of punishing him beyond his death, of course, and since fear is irrational in a huge number of cases (witness all the Covid fear porn) you push it hard -- that he will pay in eternal Hellfire if he makes YOU pay in the here and now.
Now here's the punchline: He doesn't believe it himself, which is why it doesn't inhibit his assholery in the first place -- so if you wish to inhibit his assholery you must instill fear in him of the bad occurring for his deeds in this life.
Nothing else will deter him.