The defendants' alleged harms are outweighed by the benefit the law could create for the public writ large, the judge said.