This is not the only function the doctrine of Hell serves in a society. Hell also is meant to comfort the suffering and placate their desire for instant justice (which usually ends up with a mob and a hanging). The vigilante impulse is something that society must neutralize, and the struggle to do so can be seen all through the Bible.
So Hell's use as a deterrent is a secondary function of the doctrine. Its primary purpose is to give patience to God's people.
This is the flip side of Pascal's wager, by the way. You can wait to have your justice in the afterlife, or you can exact it now.
If you do not wait and there is no God, you might or might not accomplish your justice. There's no guarantee. And even if you do, you only gain your justice for the few years you have left on earth, and then you're dead.
If you do not wait and there is a God, then you have supplanted him from his throne, and it's off to hell with you.
If you wait and there is no God, then you've gained the benefits of patience and brought a little harmony into your life.
If you wait and there is a God, then God corrects all your problems, sends all who afflicted you to everlasting torment, and you gain everlasting comfort.
Obviously, it's better to wait.
