I don’t think it’s possible to pinpoint an actual date for the invention of religion but I think it is fairly easy to see why it came about.
To understand the why I think you need to take a closer look at early mankind and their place in the animal food chain. Without weapons and the developed skills to use them man was a pretty pathetic creature little better than a scavenger living off the kill remains of other animals.
With such a primitive mind set how would you explain a sudden earthquake, a flash flood or a tribe member being struck by lightning ? The answer is you couldn’t and a fear of things so powerful and way beyond his ability to comprehend led to superstition. In a primitive mind such things were clearly the work of invisible forces, evil spirits that lived in the sky and such belief led to the creation of gods and goddesses each with a special power to punish man for any transgression.
It seems reasonable to suppose that if you have Gods then obviously you must have people who will talk to and negotiate with the Gods on behalf of the tribe. Shaman, Witch Doctors, Medicine men and the like, they became great showmen and, with a few magic tricks, became extremely powerful within the clan structure.
What happens if such men were to use such power not for the good of the Tribe or Clan but for their own purposes ? Who would dare challenge the misfortune such people could call down upon anyone who strayed from the path. After all these people spoke for the Gods !
Not too great a leap from there to religion is it ?
The real question is why after o many centuries we are still dumb enough to fall for it !