Rather than being an adaptation; most cognitive scientists prefer to describe religion as a byproduct of the evolution of several cognitive mechanisms. These include a HADD, an intrigue for MCI objects, a theory of mind, a distaste for uncertainty and anxiety, a fear of death, a propensity for ritual behavior, a use for moral and pro-social behavior, and a need to form cooperative groups. None of these cognitive biases and motivations require religious ideas, but each has found a place for them.
The mechanisms listed above have proper functions, such as detecting danger or understanding the intentions of other minds, but they've been co-opted or `hijacked' by the super-stimuli that copiously appear in religious narratives (gods and spirits). Whether this hijacking was driven by selection pressures, human motivation, or a cultural happenstance is unclear. At the very least, the evidence suggests that religion has come to fulfill a social and palliative role. For this reason, we could describe religion as an exaptation, because the cognitive mechanisms that define it appear to have acquired an additional, adaptive role to that which they were originally selected for.