When did gods first appear and why do humans keep inventing them? Ancient hominins worshipped gods. Recent archeological and neurobiological evidence suggests that as the human brain evolved, specific cognitive abilities appeared that paralleled the invention of gods and their role in human life. Gods came from the human brain.
One hundred thousand years ago, a more evolved version of Homo sapiens benefited from changes in brain structure that gave them an introspective ability, which allowed them to reflect on their own thoughts and those of others.
…
The final step in the invention of gods probably required one more advancement; this appears to have happened about forty thousand years ago when Homo sapiens demonstrate clear evidence of an ability to project themselves backward (autobiographical memory) and forward in time (based on memories). They could carefully plan for future activities with others and predict future events. Their burial practices demonstrate that they fully understood death as the termination of their own personal existence. In addition, they began to imagine alternatives to death and speculated on where their deceased ancestors existed. Frequently, they looked up into the night sky at the stars for their gods.