Why does religion continue to be so popular in today's supposedly enlightened age? In what category of things should we place religion for purposes of analysis? The least bad answer that I have come up with is: "Religion is the last protoscience."
Protoscience is most easily defined by a few well-known examples: alchemy and astrology. These disciplines can be thought of as crude, primordial versions of chemistry and astronomy, respectively, and unable to quickly divest themselves of bad theories due to an over-reliance on aesthetics as a way to truth.
If religion is a protoscience, that then, is the corresponding science? Will religion someday transform into some kind of super-science, marvelous beyond all prior imagining, and capable of robustly duplicating all the miracles of Christ, just for starters?
The science that could replace the protoscience religion is likely to be the study of adaptive, distributed, and unconscious behavioural effects in human populations. This will be a division within sociobiology focused on human swarm intelligence acting on an historical time scale. From my own examined experience, I have reason to believe that such things exist.
Alchemy is thought to have become chemistry with the isolation of oxygen in pure form by Priestly, which was quickly followed by its recognition as an element by Lavoisier, who had met Priestly in Paris and learned of the new "air" direct from the discoverer. This clue led Lavoisier to a correct theory of the nature of combustion. Priestly published his discovery of oxygen (Lavoisier's term), which he called "dephlogisticated air" (an alchemical term), in letter form, in 1775.
The corresponding intellectual hand-off from astrology to astronomy seems to have been from Tycho Brae (1546-1601), who seems to have been much involved with astrology, to his assistant Johannes Kepler (1571-1630; "The Legislator of the Heavens"), who derived three famous mathematical laws of planetary motion from Brae's data.
While the former astrology continues to this day as basically a form of amusement, and the former alchemy has utterly perished (as theory, not practice), religion continues to pay its way down the time stream as a purveyor of a useful approximate theory.
An approximate theory is useful to have if all you need is a quick and dirty answer. The theory that the Earth is flat is an approximate theory that we use every time we take a step. The corresponding exact theory, that the Earth is spherical and gravitating, is only needed for challenging projects such as travelling to the moon.
Thus, the God hypothesis is the theory of natural selection seen "through a glass darkly." However, the experiences contributing to the formulation of the God hypothesis would have been due to any cause of seemingly miraculous events over the horizon or beyond the reach of individual memory. This would comprise a mixture of the fastest effects of evolution and the slowest effects of synaptic plasticity/learning (e.g., developmental sensitive periods). However, the capacity for learning is itself due to natural selection and learning is, like natural selection, a trial-and-error process. Thus, the two sources of biological order hinting at the existence of God should usually be pulling in the same direction but perhaps with different levels of detail. Modern skepticism about religion seems to be directed at the intellectual anchor point: the God hypothesis. Since I believe that they are best de-faithed who are least de-faithed, let us simply shift the anchor to natural selection and carry on.
I think it premature to abandon classical religion as a source of moral guidance before evolutionary psychology is better developed, and given the usefulness of approximate theories, complete abandonment may never be practical. However, in our day, humanity is beset with many pressing problems, and although atheism appears to be in the ascendent, it may be time to integrate religion with science so as not to throw out any babies with the bathwater.
The modes of worship in use in many modern religions may well confer psychological benefits on the pious not yet suspected or articulated by mainstream science. Scientific investigation of the modes of worship that many religions have in common seems in order, especially since they amount to folk wisdom, which is sometimes on the money. Examples of common practices that seem to have potential for inducing neurophysiological changes are prayer, fasting, pilgrimage, incense-burning, and even simple congregating.