On religion, Hayek writes:
How can such a thing [as the extended order] have happened? How could traditions which people do not like or understand, whose effects they usually do not appreciate and can neither see nor foresee, and which they are still ardently combating, continue to have been passed on from generation to generation?
Part of the answer is of course the one with which we began, the evolution of moral orders through group selection: groups that behave in these ways simply survive and increase. But this cannot be the whole story. If not from an understanding of their beneficial effect in creating an as-yet unimaginable extended order of cooperation, whence did such rules of conduct originate? More important, how were they preserved against the strong opposition of instinct and, more recently, from the assaults of reason? Here we come to religion.
The religious view that morals were determined by processes incomprehensible to us may at any rate be truer (even if not exactly in the way intended) than the rationalist delusion that man, by exercising his intelligence, invented morals that gave him the power to achieve more than he could ever foresee.
If we bear these things in mind, we can better understand and appreciate those clerics who are said to have become somewhat sceptical of the validity of some of their teachings and who yet continued to teach them because they feared that a loss of faith would lead to a decline of morals. No doubt they were right; and even an agnostic ought to concede that we owe our morals, and the tradition that has provided not only our civilisation but our very lives, to the acceptance of such scientifically unacceptable factual claims.
Hayek echoes the thinking of both Émile Durkheim and Adam Smith. Durkheim argued that, “Religion gave birth to all that is essential in the society,” and Smith argued that, “Religion, even in its crudest form, gave a sanction to the rules of morality long before the age of artificial reasoning and philosophy.”
The Fatal Conceit: The Errors of Socialism F.A. Hayek 125-127 Taylor and Francis. Kindle Edition.