Our ancestors didn't know about the causes of volcanoes, earthquakes, life etc but they guessed it has to have a reason. They imagined that whatever was behind it has to be powerful and they called it god. But there was a problem, there was nobody who saw god or nobody who knew what all he can do. In fact they didn't have any idea about god. So they began to compare him with other powerful things they knew about or which they imagined. They compared him to the sun, the lion, ruler of the moon and also to us, giving him leadership qualities, emotions, wishes, anger etc. Then they wanted to know if we could please god and if possible how, so that they could get favors from him or because of fear or curiosity. They knew that the ways we can please someone is by offering something, respecting them, obeying them etc. So they thought it would work with god and hence came offerings, rituals and prayers. They were also curious to know where god is. But there is nobody who ever saw him and it was obvious to them that he was somewhere they couldn't see. So they imagined he may be above the sky, inside earth, under the ocean, inside the volcanoes, invisible etc. So their search for truth resulted in the concept of god, his properties, needs and wishes. It also led to the use of god as an explanation for events, phenomenon etc. But their search was guided by their imagination, fears, ignorance and limitations rather than logic. So what was really happening was, sometimes they chose the belief that they could explain things using imagination, over the reality that they didn't know about some things.
God stands for so many things for so many people. People consider god to be a person, the sun, the moon, stars, the cause of everything, everything, something that controls everything or beyond imagination. God's nature differ to different people. Some people believe that he interfere in our lives and some don't. Some may believe in gods who keep a record of what we do in our lives and use it to judge what we get after our lives. Some have gods that doesn't wait that long, they give us immediate results. Some others have gods who have planned everything out and consider us to be playing out our assigned roles. For some, gods made a system in which we get what we give so there is no need for him to interfere directly. Some have gods who have intermediaries to take care of different aspects of this world with him either acting as a coordinator or leaving it to his intermediaries’ altogether. Irrespective of how god is defined, most people who believe in god, consider him to be the most powerful, all knowing supreme being.