He's saying that religion takes the pain out of peoples lives by giving them ideas that make living less painful. Marx wants to get rid of the material conditions that cause suffering, so that people will no longer need religion.
The quote is about using materialist political movement to mitigate peoples suffering, not really about religion.
There was a post the other week where someone asked for an explainer for LTV, not one person had mentioned labor-power. Took me a while to realize why it is such an important distinction, and why Marx stresses it as so important