Yes, Karl Marx did write that, and he was wrong about many other things, as well.
Marxism is the opiate of the stupid.