You wrote: I tend to think, as with happiness, that religion has an evolutionary function--setting useful moral rules that allow us to live in larger groups and more complex societies than following our "happiness meter" would allow
For "evolutionary" I would substitute "historical" since there is little evidence that what we think of as supernatural ideas play that role in hunting-and-gathering societies, in which we evolved as a species. Sorcery and superstition probably don't even count as religion as we understand that term today, while, say, totems, or beliefs in some "great spirit" (if there were such beliefs then, I don't know) may have contributed to the solidarity of the group in its relations with other groups with which it was in competition, but this is quite different from what you suggest.
I guess what I am getting at is that there is no catch-all category as "religion" in a generic sense. Rather, there are three or four "world religions" that have arisen in historical times, which do play the role you suggest, and which build on man's apparent underlying capacity to belief in invisible forces, spirits, etc., but which otherwise are quite unprecedented in human affairs.
I think Napoleon Chagnon reported that the Yanomamo believed they could fool their gods easily when entering the underworld -- you're right that there are vast differences between hunter gatherer beliefs and those of "advanced" societies (which seem to be far less open to innovations). But that was sort of my point -- the more complex the society, the greater the need for absolutes and structured rules.