Jesse Bering has a post up at Scientific American detailing most of the major theories of religion.
Theory 1- religion is an unavoidable byproduct of consciousness
Theory 2- religion encouraged conformity, and thus religious groups were more likely to survive
Theory 3- religion is personally costly, and, therefore, by being religious people signal their commitment to the group
Theory 4- religious belief has positive effects on health, and so is selected regardless of the truthfulness of the belief
I'm a bit disappointed to see no mention of the memetic theory-- that religion is a defect which natural selection hasn't had the time to correct.