Its very complicated and revolves around early humans trying to make sense of natural phenomena and cultural differences. These early people had no science or research.They thought that horrifying things like earthquakes, flash floods, celestial phenomena, and the sun and moon were ruled by invisible gods that would send the waters to drown them, or shake the earth with his might.
This evolves from a very common thinking process in which unrelated events get tied directly to some problem, disease, or perceived punishment. Rulers learned that through this fear of the unknowable, people could be manipulated to serve and be obedient.
Incidentally, my hub talks about this very issue.