It was perhaps when the primitive people first saw lightnings making all their way from the sky, crushing the ground and burning down trees, that the pioneer ideas about a superior power came up.

In fact, it seems that the human mind is already prepared to believe in some kind of god or divinity. "A belief in God is deeply embedded in the human brain, which is programmed for religious experiences, according to a study that analyses why religion is a universal human feature that has encompassed all cultures throughout history." (see reference 1)
So, the question we will answer in this post can be put as follows:
"What might be the aims and the causes for the appearance of religion?"
You, my fellow reader, ought to understand that this post is about religion in general, and not about a particular belief. Also, the ideas developed below are merely scientific approaches of the problem and will not question the veracity of any belief.
If there is one thing we can all be sure about is that people seek happiness. Life is nothing, but a journey to achieve happiness. Even those who seem to prefer pain and suffering, they believe that those sacrifices are a means to reach happiness.
If happiness is the objective, what is the way to get there?
Basically, this is "the question", the question for which us humans have been trying to find an absolute answer, since the very beginning of our species. Religions appear not only to justify the unknown, but also as an attempt to answer that question.
The idea that a religion is a set of dogmas and beliefs is just a superficial definition. It is much more than that. It is a life style, a set of values. This is the real dimension of a religion and it is the attempt of answering the question "how to live my life in order to be happy?"
That is probably why nowadays people seem to run from religion: they are lame and afraid that a particular lifestyle suggested by a religion will not lead them to happiness. People don't run from religion because of its beliefs. Believing is easy. Living is not so easy.
There is a famous definition of atheism: the idea that the universe was nothing and a bunch of nothing exploded and created everything. (makes perfect sense, right?) So, the beliefs are not really the problem.
The main aim of a religion is to show a life-path whose end is happiness.
Then which religion to choose?
The answer to that question is inside of each one of us and is one of the gifts provided by freedom.
References