Primitive ancient people that time were living in caves, hills
and mountains, they do not know that natural phenomena like
lighting, thunders, earthquakes, floods etc are not acts of god.
their thinking was hunting, eating, protecting their tribes and
procreation.
so they begun to think that there must be a god, if not who are
creating all these natural diasters. so they begun praying to Sun,
Moon, rivers, sky because to seek their protection and create less
disasters. they thought that by praying and worshipping, the
Sun/moon god will be appeased and will bless their tribe.
as people evolved and the worshipping progressed, some even took
it to sacrifising animals and later humans to appease the god.
Here the concept of god was based on fear, as they are unable to
understand these are not acts of god, but natural phenomenon.