Propagation of societal values and/or fear of hell and/or fear of death assuaged by the assurance of an afterlife and/or being able to rationalize away the vagaries of nature as the will of god(s) are just optimizations after the core system was already invented.
There is a place for religion. Something that pushes you to be better than you are. Along with the happiness and fulfillment that comes from that effort. Selflessness, love, compassion, truth.
Plenty of bad religions telling you that you are perfect the way that you are. Just give me money, fame, or influence and I will flatter you and pump your ego.
Another form of this is flattery in exchange for hating something. Many doomsday cults fit this category. All your life problems are because of 'insert target X'. But I, I have the answers you need.
Religion is more attuned with purpose, where your heart is, than the belief in God. Though the two are often paired.
And yes, we crave purpose.
Making a giant bucket of lots of things and declaring it bad because there is something bad in there shows your ignorance.
Ignoring reasoning shows an unwillingness to learn about stuff.