It seems very likely that religious beliefs first arose in early human clans (some 130,000 years ago) when gods were invoked to counter fear and suffering. After all, our distant ancestors were traumatized by natural catastrophes, brutal weather, predators, mysterious diseases, fatal injuries, famine and tribal warfare on a regular, if not daily, basis.
At some point during our evolution, certainly by three to four thousand years ago, suffering had become more than the impetus for religious ritual; it had become ingrained in the rites themselves. We humans had come to imagine that our gods are appeased by suffering; as a result, human sacrifice, self-inflicted pain and self denial became an essential part of religious ceremony. Even today, despite our advanced scientific knowledge, such attitudes persist, represented by a wide range of beliefs and rituals, from giving up desserts during Lent to volunteering as a suicide bomber. Orders of monks and nuns retreat to lives of fasting and prayer, Catholic priests take vows of celibacy, devout believers lash themselves with reeds or whips and many (if not most) of the faithful view their earthly suffering as a ticket to heavenly rewards.
Of course, if this delusional, suffering-based faith only affected those who practice it, the rest of us would be free to focus on the enlightenment of human culture. Unfortunately, their beliefs permeate human society, stifling education, fomenting warfare, fostering intolerance and instilling fear in younger generations. Worse yet, those who view suffering as a means to salvation are more willing to inflict its scourge on the innocent. One hopes that we will eventually evolve beyond these primitive delusions but our zealous, god-fearing brethren, obsessed with their image of a vindictive deity, are not likely to fade from the scene anytime soon.