There is no doubt that religion had already waned under the onslaught of the Enlightenment but it was Freud who provided the radically new understanding of human nature that made any religious explanation of the whats and whys of our personhood seem naive.
Toxins love to get you while you're young. Lead mercury secondhand smoke and sundry other environmental nasties do a lot more damage when tissue is immature vulnerable and growing than when it's mature and comparatively fixed.