What if two same-sex parishioners of a church decide they want to be married, and want a religious ceremony in their own church (having prayed over it and believing sincerely that their God permits it), but their pastor refuses?
Then they either can’t get married at all, or they have to leave the church.
Who is to say that the pastor’s judgment of what their religion “truly” says about gay marriage, is more legitimate than the parishioners’ own beliefs formed after thought, prayer, and reflection?
If the government “stays out of it,” then pastors become tinpot dictators over this important rite-of-passage in citizens’ lives. Governments shouldn’t stand for that.
In this and many other cases you’ll find, at the end of the day, a government has to be in the business of protecting its citizens’ rights, or they will inevitably be stripped away by private parties acting as bigots.