some folks like to think law and morality must correspond.
unfortunately, what some folks think of as morality, others think of as prejudice against a different opinion.
sometimes the law protects minorities against such prejudices.
in the case of marriage rights, it turns out that the christian notion of divine morality has to submit to a legal view of the proper protections of individuals.
another example of bronze age strictures not being well-suited to a society's contemporary wants.
the moslems, of course, have the problem that both morality and law are in the hands of religious despots. and hence, no variety is permitted.