Humans ask questions. Since the earliest homo sapiens walked the earth, individuals have wondered where they came from, why they’re here, and what it all means. Religion, by and large, represents society’s attempts to answer those questions. While it isn’t always able to achieve that goal—many religious claims can be disproven by science—it often succeeds at providing followers with structure, a code of ethics, and a sense of purpose.
Religious beliefs reflect mankind's unique cognitive ability to detect agency and intention in others and, by extension, in the natural world. Early forms of religions were pantheistic, attributing to the natural world power that we would now deem supernatural. As social groups grew in complexity with the dawn of agriculture and non-migratory ways of life, religion kept pace, and continues to do so today. Its rituals and beliefs foster social cohesion and group identity, if often to the exclusion of others who do not share the same ideas.
The promise of an afterlife, a core tenet of most organized religions, is another key motivator of followers, as this belief serves an important psychological function.