Something along these lines:
Humans evolved to live in tribes, and to enjoy the benefits of cooperation and organization.
For reasons not demonstrated with certainty but likely including the human instinct to require answers to questions (such as natural phenomena, good and bad luck, sexual attraction, childbirth and fertility, death, and so on), humans in just about every known culture have evolved beliefs in supernatural beings, and stories about them ─ and perhaps also as an integrated reinforcement of tribal identity, along with language, customs, territory, folk history, stories, &c.
This trait has evolved into many forms, including organized views of the beginning to the world, the beginning of humans and animals, the power of supernatural beings, the appeasement and control of such beings, and so on.
Such forms, once they reach a certain level of popularity and organization, are regarded as religions. Priestcraft as a profession appears to be at least as old as civilization.
It's usual for them to acquire other social functions as well, such as forms of observances for birth, coming of age, pairing, childbirth, and death.
Historically it's been found convenient to include religious expressions in statecraft and politics, which may be a normal phenomenon given that politics are very usually tribal as well.
(Religions have been losing ground in the First World since modern forms of communication ─ cell phones, internet, and so on ─ have made possible new forms of community and in the process created fragmentation and bled authority from the old forms ─ governments, churches, expert opinion, newspapers and so on. )