The Emergence and Evolution of Religion.
I remember watching a documentary where birds were fed by pressing a button that randomly distributed food pellets. I showed that birds would develop rituals that were soetimes very elaborate thinking that their actions would cause food to appear, and would continue the rituals even when food didn't appear ove rlong periods of time. The conclusion was that religion and religious ritual developed by attributing significance to what are in fact just random events
From an evolutionary stand point, acquiring food in the wild would not be random and experimentation would lead to actions (rituals) which would get a bird food, and by repeating the actions it would be likely that by repeating actions that gets them food they are more likely to survive.
So, it is true that we have developed instincts that leads us toward survival by repeating actions which gave us the means to survive. However, we also apply significance to random events, which has nothing to do with survival and that is the root of religious beliefs and where religion comes from.