Strictly speaking, consistent socialists don't believe in God. Why? Because we are materialists; we believe that the world around us and the ideas in people's heads are socially conditioned. This includes religious ideas.
Religion originated with the first pre-class societies. The people in these societies lived in equality (an equality of poverty), and lived hand-to-mouth. Because of the low level of production and scientific knowledge, religion developed as a convenient way to explain things. Rain came from the rain-god, so we'd better please him; sun came from the sun-god, so we'd better please him. Religion was simply the reflection of the fact that man had almost no control over or understanding of nature; it developed as a way to explain how and why the world worked.
With the development of class societies, society's low level of prodcution increased slightly. But because of the emergence of classes, the exploited classes were subject to alienation, degradation, poverty, and lives of toil. Religious ideas provided some hope to people who had no hope. In Marx's words, it "is the sigh of the oppressed creature, the heart of a heartless world, just as it is the spirit of spiritless conditions."
But in the context of a class society, Marx also noted that, "It is the opium of the people." What did he mean by that?
Religious ideas are not only an expression of protest and anger at the existing order; they also serve to prop up the very order that exists. These ideas get in the way of the class struggle; religion promises "a pie in the sky" in the afterlife, instead of arguing for the seizure of the bakery in the here and now. The ruling class justifies its laws as God's laws, its order(s) as God's order(s), its wars as God's wars. Therefore, submission to a "higher power" also means submission to the powers that be.
The struggle against these ideas is also part of the struggle against the system which gives rise to them. But religious ideas are not always on the side of reaction and counter-revolution. If they were, nobody would believe them. Religious ideas require mass numbers of people to believe them in order for them to function; so it has to be somewhat adaptable to the demands of the oppressed and exploited. Thus many people who first got involved with the Civil Rights movement organized in chruch's with the church's protection.
Religious ideas are part of the phenomenon of mixed consciousness, which simply means that people can hold a lot of contradictary ideas, even ideas that are totally opposite one another, at the same time. Even though their religion preached about "the pie in the sky" and the succor of heaven, thousands joined the Civil Rights movement to fight racism and segregation in the here and now. Even though religion encouraged submission, many thousands became activists.
The danger of religion is that, at a crucial moment in the class struggle, it will preach conciliation, nonviolence and class peace, thereby giving the rulers the upper hand with which to smash the working class. Religion cannot provide an analysis of the world that leads people to an understanding of how to change it - it declares that what is is and what is not is not because God did not want it to be so.
I'd like to end this article with a quote from Karl Marx, which is the basis of the revolutionary socialist attitude toward religion:
"The basis of irreligous criticism is: Man makes religion, religion does not make man... Religion is the sigh of the oppressed creature, the heart of a heartless world, just as it is the spirit of spiritless conditions. It is the opium of the people... The demand to give up illusions about its condition is the demand to give up a condition which needs illusions... Criticism has plucked the imaginary flowers from the chain not so that man will wear the chain without any fantasy or consolation but so that he will shake off the chain and cull the living flower... Thus the criticism of heaven turns into a criticism of earth, the criticism of religion into the criticism of right and the criticism of theology into the criticism