So, where did religion come from?
I suppose we can hypothesize what people thought and felt before records were kept, but this question is deeper than that.
The jump from there to the theology we have today is not obvious.
This is especially true in regard to the issue of pain.
For in what way can the concepts of goodness and virtue metaphysically follow out of suffering and void?
Maybe something revealed? Or something in our hearts all-along?
Living a life that ignores this is, shall we say, taking a lot for granted.
If the universe is so bad, or even half so bad, how on earth did human beings ever come to attribute it to the activity of a wise and good Creator? Men are fools, perhaps; but hardly so foolish as that. The direct inference from black to white, from evil flower to virtuous root, from senseless work to a workman infinitely wise, staggers belief. The spectacle of the universe as revealed by experience can never have been the ground of religion: it must always have been something in spite of which religion, acquired from a different source, was held.
-C.S. Lewis, The Problem Of Pain (Amazon)