According to Marx, religion plays a role in reproducing and justifying existing class inequalities, preventing a revolution, enabling the ruling class to justify existing social divisions and keeping a supernatural check on the ruled class.
Evidence for Marx's argument can be found in the Hindu caste system and Medieval Christianity.
For Marx, he was influenced by the French revolution, which led to the execution of the King and the rise of the bourgeoisie. He states the next revolution required the proletariat to overthrow the bourgeoisie and needed an assault on religion.