First of all its a mixture of two things:
We have strong need to understand the things we dont understand, this is because it has been essential to our survival. Lets say you are some early human living in a forrest, and you hear some branch on a ground making a cracking sound. Now your life depends on whether you can make an fast intuitive assumption(which you trust) that it might be a predator stalking you and stepped on something, because its too late after it attacks you. But this sort of intuition is evident in animals also, so this alone doesent make us to believe in god.
What the development to atart believing in god also reguired was us to start pondering on larger scale unknown things. As we started to get more able on pondering larger things we also got more able to make bigger intuitive leaps in our cognition. Now that we had eliminated large part of our enemies, we could start thinking about things in more depth and start thinking about things that werent so essential to our survival. "I created this spear from that tree which helps me on hunting, but who created that shiny thing on the sky that helps us to stay warm and gives us light to see properly, why is it going away some times, there must be someone bigger than us moving it" etc etc
Thus man created god in his image.