A much misunderstood quote. Opium was not the evil addictive waste then that it is now. It was a balm, one of the few anesthetics available, something people with bad teeth or painful diseases were very grateful for - if they could pay for it. It wasn't that cheap. The masses were largely denied that comfort, one of the many sharp and ugly distinctions of class in Marx's day.All Marx said was that religion was the opium of the masses,
A distinction that is coming back - anesthesia for stitching wounds, abscessed teeth, corneal scratches, handling temporary healing times of pain, is available only by prescription, and doctors are being priced out of the range of the poor in the US.
Marx did not spend much time on theistic speculation, and even if his undermining of a social hierarchy closely identified with the local religion could not help but throw doubt on the religion as well, subsequent developments have proven that communism and even Marxism is perfectly compatible with Christianity, Judiaism, and I think Islam.