Where does religion come from?
I regard the wide spread of religion as perfectly well explained by the fact that it is a behaviour pattern evolved for survival in a pre-scientific era of history, and so, like the fighting instinct, obsolete in the scientific age. Many (but not all) boys, youths, and young men tend to fight over resources (including girls) in precisely the same behaviour pattern as male lions, stags, bull elephant seals, and a million other species from beetles upwards, fight over females as part of their typical behaviour pattern. Young men still tend to do this, even in so-called civilized western society, unless they are civilized out of it by their parents and by schools, and educated into resolving their differences in other ways. The behaviour doesn't arise from nowhere in each generation: it is the results of millions of years of evolution and is deeply rooted, but nowadays it is unnecessary and generally considered to be (put basically) rather primitive and "wrong". But that last attitude is very recent, and accepted as the correct attitude barely half a century ago — within our lifetimes. Plenty of strata even of western societies do not share it yet. Duelling over women has been banned for a couple of hundred years in Britain but that is a very short time in evolutionary terms.
In exactly the same way that fighting among rival males has emerged, human beings have evolved with a brain that seeks explanations for everything, and that latches onto apparent patterns of cause and effect. However this is not intrinsically sophisticated: many species, even pigeons, can be seen to possess such behaviour. So, in the absence of scientific knowledge, people have for eons developed superstitions, which are spurious cause-and-effect patterns mistakenly believed to be significant; and from that stage come religions, which are elaborate, often highly structured, collections of superstitions, typically adopted by an entire society (always with a few exceptions who tend to have to hide their detachment or risk becoming outcasts) and elaborated even further by a class of individuals that tends to emerge in each society, and which can be referred to as the priesthood of that society, of that religion; and thereby, with the emergence of writing, the phenomenon of "scriptures" emerges: scriptures are typically regarded as objects to be revered, especially in the early stages of societies when literacy is reserved for a small minority, and those texts then continue to be revered even when literacy becomes almost universal in each society — simply because by then the attitude of reverence is so long established.
Now, unless you are ahead of me in this argument, you might now ask: how does religion benefit the society and thus develop in the gene pool? But the answer to this is fairly obvious: religion is a form of literature. Think of it as the extended family — the whole tribe, in fact — sitting round the fire in the evenings with one of the elders with a good memory telling the stories, the only difference between this and Jackanory being that the stories ae presented as the truth. The development of the Greek myths and legends is known to have been by retelling of the tales as the pseudohistoric heritage of the tribe. Small children do not initially have a clear idea of what is real and what is pretend. The ability to distinguish these categories develops, but it is well known that even after they supposedly know the difference they love blurring it. They often hate the moment of discovery that Father Christmas is a fantasy. It is easy to see how stories told purely from imagination can be repeated over generations to the point where they become almost part of reality; the same applies when genuine historical tales about forbears or famous events that genuinely happened in the past are embroiderred with repetition, so that they build up into fantasy with barely a narrow thread of historical reality left, after generations. I mentioned the Greeks; apart from Zeus and his family's doings we have the Norse sagas and the tales from British pre-history as examples of how tales get elaborated, retold and embroidered until eventually written down. Where the writing down is at a stage in the tribal history at which the orthodoxy is that those tales are true, and are systematically used as normative lessons for the ethos and morality of a society, you have all the makings of t a religion complete with its "scriptures" or "holy" book.
The fact that it can be seen how religions thus emerge as a product of evolution for survival does not make religions correct. The very opposite, in fact: just like the tendency of males to fight (possibly to the death) over females, religion is merely a behaviour pattern that proved successful for survival of the gene pool of a human society at a given stage in evolution. Indeed, the simple fact that the actual beliefs of various religions around the planet are totally at odds one with another makes it obvious they cannot all be correct; for any adherent of a particular religion, all the contradictory beliefs of all the other religions must be wrong. Therefore it is logical for the detached observer to conclude that all the beliefs of all the religions, insofar as they ar not supported by scientific or historical evidence, are spurious,and therefore merely either what emerged in the superstition stage or what was made up (invented) at some stage or another by the priesthood of the religion in question; and we can say assume that such inventions occurred either during the era when that religion's "scriptures" were being written or later, during the much longer exegesis stage.
For Christianity, the exegesis stage would be from around 200 AD to the present. The writing was no doubt by a variety of people over a considerable time before the Christian era. Does that make it worth "believing"? No! Of course not. The "Bible" is a bronze age Narniad. What is ironic about C.S. Lewis's efforts is that (having grown up an atheist) he apparently wrote the Narnia heptalogy as a piece of cryptic Christian apology (at least, that is what most of his modern heart-on-sleeve Christian fans seem to claim) after his adult conversion to Anglicanism on return to Oxford university after a hellish time in the trenches in the First World War. And a noted recent exegesis of the Narniad is The Narnia Code, which is by an Anglican clergyman. And yet the very existence of the series, with all the layers of allusory meaning claimed by The Narnia Code clearly demonstrates how it is possible for a single writer to invent an entire world, a mythology, with layers of meaning and pseudo-religious overtones, in a simple (if fairly prolonged) act of imagination. If Lewis could invent the "land" of Narnia and the characters and events in all his stories about it, a bunch of people with just a tiny bit more than the average amount of imagination could easily invent all the claimed marvels and miracles of both the old and new testaments of the Jewish and Christian "Bible".