Karl Marx famously described religion as the opium of the people. He saw religion as a tool used by the ruling capitalist class to oppress the proletariat. There would be no need for religion in a properly functioning Communist society, and this alone would have been reason enough for Stalin to attempt to eradicate it. However, Stalin had another motivation, too. He hated the idea that his people might believe in a power even greater than his own.
Russian Orthodoxy was the dominant religion in the Soviet Union, but there were also substantial numbers of Catholics, Protestants, Jews, Muslims, and others. The process of attempting to stamp out religion began under Lenin, but it accelerated under Stalin. Religious works of literature were banned, and atheism was promoted in schools. Worshippers were harassed, their places of worship closed or even destroyed, and priests and preachers targeted by the secret police.