Before I conclude this post I would like to address a very common misconception about evolutionary theory. Evolution is 100% random. The environment of where an organism lives has no difference on the kinds of mutation that could possibly occur. However, the environment does have a direct affect on which mutations are beneficial to an animals survival and thus which mutations will stick around. For example if an animal in the jungle was born white it may not live very long because it would stick out (most likely be eaten), however if this mutation occurred in the Arctic it would be very beneficial.
Our human brains have been in constant evolution from primitive brains that evolved in a common ancestor (creationism says we were created as humans). Well our brains are more complex than other animals because the humans with more complex brains reproduced more often and so we are their descendants. Now in ancient times there was very little known about science and the on goings of life so people turned to religion to answer many of these questions. There have been studies on the brain in order to find a "g-spot," or God spot, which is the theoretical part of the brain that creates the very idea of a God. The studies found that when people are most spiritual that not just one part, but multiple regions of the brain are very active. What does this mean? There is no one section of the brain that believes in God. This could mean that the brain developed as a whole to believe this.
Well if that's the case then it must have evolved to be this way. The only reason I can come up with something like this occurring is if a religion is beneficial to survival. This is true. In ancient times life was pretty rough. In order for people to even survive a sense of cooperation must be achieved and religions promote this. Help your neighbor, its all for the greater good, etc. these all ensure that individuals survive. Another aspect is religions promote peace (usually, exception of Holy wars and Dark Ages) and this prevents killing of the human race. Another positive aspect from some religions is monogamy, this is allows for more care to hopefully be given to one's own offspring. It would be harder to care for your young if you have 2 or 3 different families. Though this theory of religion being beneficial to our survival may be a little far fetched, it does offer explaination for why a human brain would evolve to be stimulated when spirtitual. There are in fact many other explainations and if you have one please tell me about it in a comment!