Moby
Dick
Religion existing prior to us having any understanding of our nature made sense simply from a giving a name to everything that was mysterious to us. As has been pointed out, a lot of ancient gods revolved around natural phenomenon because people couldn't make sense of it and had no means to understand it. They didn't understand how rubbing stones created fire or why water started pouring from the sky, and used the concept of a mysterious force and gave it names.religion is universal. there's something about human nature which places some analogue of religion everywhere. in pre-industrial societies it would be called animism. then you have atheists who believe in something which is almost religious. the idea of mathematics as "divine", or to know the mind of "god" as Einstein said speaking about the connection between natural science and all things. religious institutions, broadly speaking, are evil.
However over time those things have been cleared up, and none of it is any kind of mystery. Which is why the same concept was taken and converted into more of a moral code rather than something that just gave a meaning to natural phenomenon, when in reality there was zero need of having any mysterious entity getting associated to a moral code. Moral code exists in all living species, fecking ants get the fact they need to preserve their own species, as did humans. Hence the entire scepticism around these things having anything to do with morals in the first place.