junebug, greed, fear, and other 'negative' impulses are survival traits. They exist because of evolution - an organism that doesn't have at least some greed may not get enough to eat, an organism that does not feel fear will probably be eaten by a predator that it wasn't afraid enough of to watch for. They're both things that any successful organism has to have in order to guarantee its survival.
Furthermore, it's impulses like these that led to beliefs in gods to begin with, since a belief doesn't occur for no reason. Because of fear, people attributed strange, unexplainable, fearful events to super-powerful beings that they imagined causing them (whether monsters, demons, devils, or gods). Because of greed, people sought to get the favor of these beings, or at least avoid the disfavor of them. If it worked, it was 'proof' that they had succeeded, and they would keep repeating it; if it failed, it was 'proof' that they needed to do more than that. And once they have the belief in something, they cling to it like someone adrift in the middle of the ocean would cling to a life preserver or even a piece of driftwood.
Belief comes from impulses, junebug, even today. That's how you explain the difference between 'good' beliefs and 'bad' beliefs. A greedy person will believe in a god who will help them fulfill their greed; a fearful person will believe in a god who will assuage their fear; a lonely person will believe in a god who is all about love; a hungry person will believe in a god who will help fulfill their needs. But they all come from the same source, impulses that want to be fulfilled.