It is believed that humans evolved agent detection as a survival strategy. In situations where one is unsure of the presence of an intelligent agent (such as an enemy or a predator), there is survival value in assuming its presence so that precautions can be taken. For example, if a human came across an indentation in the ground that might be a lion's footprint, it is advantageous to err on the side of caution and assume that the lion is present.
Psychologists Kurt Gray and Daniel Wegner wrote:
“ The high cost of failing to detect agents and the low cost of wrongly detecting them has led researchers to suggest that people possess a Hyperactive Agent Detection Device, a cognitive module that readily ascribes events in the environment to the behavior of agents. ”
Role in religion
Some scientists believe that the belief in creator gods is an evolutionary by-product of agent detection. A spandrel is a non-adaptive trait formed as a side effect of an adaptive trait. The psychological trait in question is "if you hear a twig snap in the forest, some sentient force is probably behind it". This trait prevents the primate from being murdered or eaten as food. However this hypothetical trait could remain in modern humans: thus some evolutionary psychologists theorize that "even if the snapping was caused by the wind, modern humans are still inclined to attribute the sound to a sentient agent; they call this person a god".
Kurt and Wegner also said that agent detection is likely to be a "foundation for human belief in God" but "simple overattribution of agency cannot entirely account for the belief in God..." because the human ability to form a theory of mind and what they refer to as "existential theory of mind" are also required to "give us the basic cognitive capacity to conceive of God." 
- Henig, Robin Marantz (Mar 4, 2007). "Darwin's God (Page 4)". The Times Magazine. NYTimes.com. Retrieved Dec 21, 2010.
- Gray, Kurt; Daniel Wegner (Feb 2010). "Blaming God for Our Pain: Human Suffering and the Divine Mind". Personality and Social Psychology Review (Sage) 14 (1): 9–10. doi:10.1177/1088868309350299. Retrieved Dec 21, 2010.
- Religion Explained, by Pascal Boyer
- Henig, Robin Marantz (Mar 4, 2007). "Darwin's God (page 3)". The Times Magazine. NYTimes.com. Retrieved Dec 21, 2010.