When trying to explain the origin of religion, we must answer the question of how it came together, since although human beings are social animals, the act of creating a stable institution is an extreme rarity. Consider how many cults come and go; obviously, even if there is a fundamental need to be religious, there must be some explanation as to why humans would continue to participate and develop their religious institutions.
Human beings are as cooperative, altruistic, and caring as they are selfish, disloyal, and uncooperative. If a system is to work, then it must function in such a way that each person operating within that system must agree to act in accordance to the benefit of the group, and not their own self interest. This is not easily achieved, since there may come a time when the self interest of an individual conflicts with the interests of the institution. How can a person blatantly ignore his own needs in favor of the group, particularly if this group is not his direct kin?
The simple answer is in a large group, not every operator needs to benefit from being a member of the group; only the majority needs to. We already have this sort of arrangement in our own society. Some benefit more than others, simply by the manner of their birth. Their parents may have more wealth, and as a consequence, have more opportunity than others to move ahead in life and reap the rewards from their privileged status. The reason we don’t rebel and displace such individuals is the majority of us still benefit from the system. There are big winners and big losers in this game, but generally, if you want social stability, the numbers of both (particularly the latter) must remain fairly low.
The complex answer is each human being, to some degree or another, has wants and needs that cannot be fulfilled alone. It is not important that perhaps living in a group, or following a religion may not fulfill those needs; it is only important they present themselves as the only way to do so. When Christians proclaim themselves the only way to live a fulfilled life, and torment, torture, and murder are the consequences of disbelieving, then the stakes are high enough for any rational person to want inclusion in the group. Independence and free thought is discouraged when the benefits to the individual require cohesion of belief from all involved. From a survival perspective (especially in early civilizations), any personal doubts regarding the authenticity of religious claims were less important than being part of a advantageous and beneficial institution.