Scientists are beginning to discover how religion is recognized by the brain, thanks to the field of neurotheology. This new advancement combines two things: religion, which is a set of beliefs that activate different parts of our brains, and theory of mind, which is the ability to interpret one's own and other people's emotional and mental states including desires and beliefs. Neurotheologists theorize that religion and theory of mind may be connected by people’s ability to imagine a reality beyond their immediate sensory experience. If true, then the same parts of the brain that activate during theory of mind tests will also activate when thinking about God.
And that’s just what scientists have found. In a study where 15 Christians and 15 “non-believers” were asked about the existence of God, the ventromedial prefrontal cortex lit up in all participants. This region of the brain is specifically responsible for reward and perception of self-relevance.
Another part that lit up was the anterior cingulate gyrus. This part of the brain is thought to modulate conflict, errors, and violations of our expectations. This suggests there was a degree of internal conflict when asked to think about a higher power. Even non-believers had this area light up because even if they didn't believe in religion, they still believed in something.
Despite the perceived differences between religion and science, it's likely that as the prefrontal cortex developed to allow humans more abstract thoughts, religious systems and beliefs developed to help people understand each other and connect to a higher purpose. This neurological theme of prosociality is a common one among world religions, but most know it by a different phrase: "love thy neighbor".