We should not forget what a potentially powerful instrument of social control a religion can be. The concept of eternal damnation in a fiery hell must sometimes be a powerful deterrent against bad behaviour for certain believers, just as the concept of a life of eternal bliss in a heaven is an alluring reward for good behaviour.
One wonders just how many people throughout history have refrained from acts of theft, assault and murder as a result of their considering the consequent punishment of such actions after their death.
I'm reminded of a quote from Mohammed,
"This world is like a prison for the true believers, but a paradise for the non-believers." The implication here is that the true believer who dutifully tolerates the prison rules will be rewarded in heaven, perhaps even with a few virgins if he's a male; whereas the non-believer who wantonly satisfies his lusts and lascivious desires will meet with eternal punishment after death, which will be much more severe, of course, than any prison sentence on earth.
I'm also reminded of the following passage from Mathew 5.29, which seems to express a similar sentiment that it's better to rigidly comply with certain rules and restrictions, such as refraining from lusting after women, rather than be cast into hell.
And if thy right eye offend thee, pluck it out,
and cast it from thee: for it is profitable for
thee that one of thy members should perish, and
not that thy whole body should be cast into hell.
Although, to be reasonable, if thy right eye offend thee, I think it would be better to wear an eye patch instead of plucking out the eye.