When I say morality, I mean standing up for basic things like marriage and life, not simply anything that has to do with religion. This ban would not criminalize people for being gay and engaging in gay behavior, rather it prevents them from getting married and so their union cannot be recognized.
As far as religion goes, several different ones are practiced. Lots of different ideas, and you can’t force people into one or the other, they have to decide for themselves. But generally all of them view homosexuality as immoral. Those that don’t aren’t moral. The Ten Commandments apply only to Christians, so criminalizing everyone wouldn’t be possible. Seeing homosexuality as immoral applies to everyone (except atheists or those who don’t practice their religion), so banning it would be done on a moral ground.
Another thing: The reason there isn’t a law criminalizing those who don’t follow the Ten Commandments is because you can’t force Christianity upon them, they have to discover for themselves that it is the religion they want to follow. When forced upon them, they are not really following it, they’re just doing so because they have to.
With gays, again you can’t regulate what they do in their private lives regard homosexuality, there’d be no way to keep track of everybody and possibly enforce it, but you can work on a public scale and prevent them from getting their unions recognized.
I'd say the same argument you're using for this could be used to rationalize virtually any exercise in federal social or cultural engineering.