Marx was not a particular zealous advocate of religion. He argued that religion was a condition that impeded a critical view of existing structures that enveloped individuals. For Marx, religion was a a force that prevented individuals from recognizing the true essence of their being in material reality.
Marx objected to religion occupying a significant role in society because it precluded the full understanding of dialectical materialism. In borrowing from his teacher, Hegel, Marx suggested that the transcendent condition in being in the world was the dialectical process, and specifically, dialectics that understood the role of material reality in defining consciousness. For Marx, religion prevented this condition from being fully recognized because it supplanted dialectics with divine faith. Marx believed that for individuals to gain a true understanding of their place in the world, religion had to be shed:
The abolition of religion as the illusory happiness of the people is the demand for their real happiness. To call on them to give up their illusions about their condition is to call on them to give up a condition that requires illusions. The criticism of religion is, therefore, in embryo, the criticism of that vale of tears of which religion is the halo.
In order to evade the idea of "illusory happiness," Marx advocates an abolition of religion in the social setting.
In his critique of capitalism, Marx suggests that those in the position of power will employ any means in order to perpetuate the Status Quo of economic disparity. In keeping the proletariat in check, religion is often used as means to sedate individuals, preventing them from asking the critical questions that could initiate change. Marx's logic argues that if individuals embrace religion without much in way of question, they will be less likely to question the material causes that reflect exploitation, dismissing it as "the will of the divine" or even justifying it as a test from the divine. It is in this light where Marx suggests that religion is an "opiate for the masses:" "Religion is the sigh of the oppressed creature, the heart of a heartless world, and the soul of soulless conditions. It is the opium of the people." In this regard, Marx does not see an effective purpose for religion in modern society.
Karl Marx did not particularly enjoy the thought of religion. He grew up a Jew, than a Lutheran, and ultimately turned to Atheism mostly because he saw religion as a social burden.
He also saw everything as a matter of society, which led him to express most of his ideas through the reasoning of economics.
The abolition of religion as the illusory happiness of the people is the demand for their real happiness.
Meaning, he saw religion as unnecessary social institution that was only really used for people who needed something to cling to in times of despair.