Theories about how religions started or where they come from are numerous. However, some of the most recognized or agreed upon ideas related to how religion started are connected with the way archaic humans interacted with the natural environment that surrounded them in the past.
For instance, let us take an archaic human at random that walked the earth many thousands of years before us and might serve as a useful example: The Homo Neanderthalensis. As they were out on the planes or in the jungle gathering food or getting ready to feed themselves or their families, they might come across a sudden movement in front of them or in the pastures next to them and instead of waiting around to think or ponder over what it might be, they would immediately assume the worst case scenario, getting ready to defend themselves or save their lives. In other words, the fight or flight response or instinct would immediately kick in. This is because any movement in the pastures could indicate a potential predator lurking around waiting for their chance to jump on their prey.
For example, they knew a predator had autonomy and behaved in a certain manner. But for example, humans started attributing certain inanimate phenomena, like a tornado, or a storm, autonomy as well; and thus, humans believed that a fire or lighting might strike exactly in a specific point because “it wished” to do so, much like a predator. That is when the belief in the supernatural arose and things went south. Archaic humans would now start believing that a storm was befalling a certain region for a reason or purpose.
So, one good day, humans began attributing the movements of the celestial bodies around them to “agents with supernatural powers” such as deities, spirits, fairies etc. Much like a marionettist. This inclination to account for natural phenomena through the supernatural was what paved the way for religious thinking.