From Freud’s The Future of an Illusion, which should be required reading for any thinking person—
We know that a human child cannot successfully complete its development to the civilized stage without passing through a phase of neurosis sometimes of greater and sometimes of less distinctness. This is because so many instinctual demands which will later be unserviceable cannot be suppressed by the rational operation of the child‘s intellect but have to be tamed by acts of repression, behind which, as a rule, lies the motive of anxiety. Most of these infantile neuroses are overcome spontaneously in the cause of growing up, and this is especially true of the obsessional neuroses of childhood. The remainder can be cleared up later still by psycho-analytic treatment. In just the same way, one might assume, humanity as a whole, in its development through the ages, fell into states analogous to the neuroses,‘ and for the same reasons – namely because in the times of its ignorance and intellectual weakness the instinctual renunciations indispensable for man‘s communal existence had only been achieved by it by means of purely affective forces. The precipitates of these processes resembling repression which took place in prehistoric times still remained attached to civilization for long periods. Religion would thus be the universal obsessional neurosis of humanity; like the obsessional neurosis of children, it arose out of the Oedipus complex, out of the relation to the father. If this view is right, it is to be supposed that a turning-away from religion is bound to occur with the fatal inevitability of a process of growth, and that we find ourselves at this very juncture in the middle of that phase of development.