It is a reasonable surmise that after the killing of the father a time followed when the brothers quarreled among themselves for the succession, which each of them wanted to obtain for himself alone. They came to see that these fights were as dangerous as they were futile. This hard-won understanding as well as the memory of the deed of liberation they had achieved together and the attachment that had grown up among them during the time of their exile led at last to a union among them, a sort of social contract. Thus there came into being the first form of a social organization accompanied by a renunciation of instinctual gratification; recognition of mutual obligations; institutions declared sacred, which could not be broken in short the beginnings of morality and law. Each renounced the ideal of gaining for himself the position of father, of possessing his mother or sister. With this the taboo of incest and the law of exogamy came into being. A good part of the power which had become vacant through the father's death passed to the women; the time of the matriarchate followed….The relationship to the totem animal retained the original ambivalency of feeling towards the father. The totem was, on the one hand, the corporeal ancestor and protecting spirit of the clan; he was to be revered and protected. On the other hand, a festival was instituted on which day the same fate was meted out to him as the primeval father had encountered. He was killed and eaten by all the brothers together…This great day was in reality a feast of triumph to celebrate the victory of the united sons over the father.
Where, in this connection, does religion come in? Totemism, with its worship of a father substitute, the ambivalency towards the father which is evidenced by the totem feast, the institution of remembrance festivals and of laws the breaking of which is punished by death--this totemism, I conclude, may be regarded as the earliest appearance of religion in the history of mankind, and it illustrates the close connection existing from the very beginning of time between social institutions and moral obligations. S. Freud MOSES AND MONOTHEISM
There is a lot going in the passage quoted from Freud (and even more with what he wishes to do with it in in the book's overall argument), and I focus on a partial aspect of it here. I propose to read him not as an anthropologist or a social psychologist here (or Biblical exegete), but as a social theorist.
Not unlike others in the pre-Rawlsian social contract tradition, he posits a kind of patriarchal state of nature that precedes the social contract. (The patriarchal rule is reminiscent of the darkest fears that folk project onto Hobbes's or Spinoza's Sovereign.) In the state of nature parricide is followed by civil (family) war—crucially an even worse state of nature. The contract is not a consequence of fear, accumulation, or reason, but a sense of futility. That is to say, on this account, the social contract becomes possible when open-ended civil war exacts high enough costs, but cannot be won. That is, in fact, a very optimistic thought.
On Freud's account, the contract consists, in large part of the development of norms about what counts as reasonable expectation and aspiration (and what is off-limits/taboo). What is notable about Freud's analysis is that he does not share the social contract tradition's obsession with property; he is more focused on the way the contract governs 'real' and symbolic relations among humans, not the things they possess.
Concern with (symbolic) things is left for religion. Regardless of the empirical status of Freud's account of totemism, what I find striking is that the birth of religion is a necessary consequence of the contract (it's what I would call a 'conceptual-necessitation-relation' or a forced move). Not so much (i) as an means of control of the folk that participate in the 'union,' (although its status as a civic religion ensures it is that, too), but as (ii) a way to recognize (in a side-glance-kind-of-way) the inherent instability of the contract, as well as (iii) a means to re-enact in a domesticated way the process that led to the social contract in order to secure the contract and thereby (by reenacting, that is (iii)), ensuring (iv) ongoing recognition of the most important political facts of society. Religion, then, conveys political truth not so much in its cosmology or cosmogony (or metaphysics), but in the practices it instantiates (and re-enacts). Note that on this view religion is not merely functional, but in the practices it cultivates the symbolic source of political wisdom. So, while it may seem that Freud is debunking religion in the book (and throughout the book he calls attention to this possible reading), and I understand the temptation to put him in the company of Marx and Nietzsche, it is, in fact, possible to read Moses and Monotheism as a defense of the idea that philosophy is entirely dispensable in the political life of the community if there is a kind of 'original' religion. (Of course, Freud allows that the religion can be corrupted as much as developed.)
The contract is very gendered in Freud, but despite the fact that it involves only boys as agents, the consequence is the matriarchate. On re-reading, Freud loves this kind of ironic unintended consequence explanation.