Marx did not believe that religion commanded human activities; he did not believe that laws could be moral according to God, immutable and unchanging.
He incorrectly believed the converse, that religion was a function of human activity and therefore was relative to economic need and societal mores.