Sigmund Freud discusses his views on religion and what he sees as a "universal obsessional neurosis" in his early work, Obsessive Actions and Religious Practices. He expands on his views in his later works. Freud believes that people use religion as their excuse for not correcting glaring inconsistencies and for accepting many things at face value. He accepts that, for uneducated people, a sense of right and wrong can sometimes only be assured if there is a belief in a higher power, urging them towards good choices but, for a reasonable and educated person, morality does not need a religious basis.
Religion sometimes requires certain customs and traditions to be followed dutifully and faithfully, without question. Neuroses cause a person to dutifully and faithfully carry out certain tasks -even when they are based on obsessive behaviors. Hence, there are some who would categorize such religious customs as lighting candles, the Rosary, daily attendance at church, praying facing Mecca, etc as similar to obsessions.
Freud maintains that religion prevents people from exploring other avenues of thought which therefore restricts their understanding. Neuroses cause people to act irrationally, even when the know there are alternatives. it is as if the alternatives should be ignored. Again a perceived similarity.
Freud was a Jew although he considers it more of a nationality than a religion. His psychoanalytical approach has been criticized by many who actually see parallels between his own beliefs and religious beliefs, in that, neither, in the opinion of some of his critics, carry scientific proof but relate to subjective experiences. It is ironic then that, in setting out to show that following a religion is comparable to neurotic behavior, he has exposed his own approach to the human mind as, perhaps, being akin to some forms of neurosis itself.