I think religions came about because it filled a psychological and explanatory gap in peoples lives. Human beings have a need to feel they belong, that they are special and to tell them how the world and you cant get better than a bearded superbeing to provide that. He loves you, "you" is a group of like minded people and questions like "How does the sun work?" can be answered with "Magic/god does it".
I think that religion continues because children are indoctrinated into it and so never have to move beyond those things. Similar to racism which we know is often prevalent in families because children who learn things very young do so before they have the mental capacity to really consider these ideas.