Many psychologists in the Jungian school of thought have said that the gods are instances of the archetypes.
Archetypes are the content of the collective unconscious.
The collective unconscious is said to be a sort of racial memory, which everybody shares in common. My guess is that it might be a sort of social and interpersonal catalog. Like a database with a folder of instructions telling how each type ought to relate to each of the other types. Archetypes come in male and female. For men, they are the father, the son, the hero, and the wise man.