Over that last two years, I’ve spent a lot of time trying to understand the sacred. First I collected a list of things that people say correlate with our treating things as sacred, and then I looked for general theories that could explain why humans might have a behavioral pattern with these correlates. In the story I prefer (a story proposed by others, extended by me) humans long ago evolved a general capacity that functions primarily to bind groups together by their shared view of certain special things. Different groups treat different things as (more vs less) sacred, and it matters less what a group treats as sacred than that that group treats the same things that way.
I’ve come to realize, however, that those who are most invested in the idea of the sacred tend to object to this approach. In their minds, first there were special things that naturally deserved to be treated in a matching special way. Then humans were shaped (i.e., evolved or designed) to reflect these facts, and thus came to treat these special things in a matching special way. Finally, many humans lost track of which things deserve to be treated most sacredly, but retained a hunger and habit for treating some things as sacred. So they mistakenly came to treat many other less deserving things as sacred.
For example, some say that humans have a “God-shaped hole” in their hearts, a hole that we try to fill with other things, but we remain unsatisfied until we put God in the hole.
So either some things really are sacred, and deserve to be treated in a special matching sacred way, or we evolved to feel this way in order to achieve some other function, of which we are usually unaware.
Now I’m not going to be able to settle this question in this post. But I do want to make one key observation: if humans were shaped to treat a truly sacred thing in a special sacred way, then this special sacred thing can’t be a recent or as yet undiscovered thing. Most of our shaping wasn’t recent, and so if that shaping reflected distinctive features of certain special things, those things also cannot be only recent. Our ancestors, or their creators, must have had substantial experience with and exposure to these special sacred things and their many distinctive features.
For humans to have been shaped long ago to treat the sacred in its appropriate sacred manner, the sacred must have been around long ago, and important enough then to shape our natures. That is, if the sacred is real, it must be big and ancient.
I recommend DS Wilson's book Darwin's Cathedral on this topic, along with the relevant parts of Haidt's The Righteous Mind. They make a compelling case that religiosity evolved to foster collective action. And true believers don't have to go through the kind of cost-benefit calculation they otherwise would when thinking about whether to contribute to public goods.
I’ll add another option from my faith tradition (LDS). Rather than an ancestral longing for God, we have a longing for God derived from each individual’s pre-mortal experience with God. We all lived with Him as spirits in a pre-mortal existence and now, though we don’t remember that, we naturally have an innate yearning to return to His presence, and to experience a spiritual connection with Him on Earth.