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. The collective unconscious is said to be present in every person. If there is such a thing, it must have had an adaptive value for our species at some time in our evolutionary history, or else we would not have evolved the mechanism. If each person knew subconsciously how to relate to all other social types, that knowledge would serve to adapt them to their cultural environment. The frequency of aggressive behavior might be lower with a collective database than without one.