Two theories have gained some acceptance amongst modern scholars.
One is the spirit theory of religion, the other the evolution of the idea of the Infinite. ...that religion originates in the personification of the power of nature.
One party maintains that ancestor worship is the beginning of religious ideas;
Man wants to keep up the memory of his dead relatives and thinks they are living even when the body is dissolved, and he wants to place food for them and, in a certain sense, to worship them. Out of that came the growth we call religion.
THE NECESSITY OF RELIGION
Lecture in London