So, let’s start with a definition: the morally good thing is the thing that increases the net good, all persons considered. That’s utilitarianism, in my own words :).
Now, a real life example — the North Carolina bathroom bill — or, ‘potty law’. That law more or less requires public bathrooms to be restricted to persons of the “biological sex on the birth certificate”.
What the law was responding to was local laws in Charlotte, NC — that included protections for trans rights. What would mean, in terms of bathrooms and other gender-segregated facilities like locker rooms, is that trans women would be permitted to use the women’s room, and trans men would be permitted to use the men’s room.
This — of course, set the pervert-hunters aflame– because, of course, it meant that teenaged boys could “claim” to be trans for a chance to go into the girls’ locker room… or that an adult man could put on a dress and hide in wait for women/ girls in the women’s room, in order to assault them. There was also a general sentiment that somehow trans persons would be more likely to attack in the bathroom.
The claim of the potty law supporters is that the “vast majority” of people are “on their side”. Let’s just assume that’s true for the sake of argument, then look at the evidence and do some moral reasoning.
Of the 14 or so states that include full protection for trans rights.. none of them have reported even ONE incident of a trans person attacking anybody in a bathroom. On the other hand, about 70% of trans people (.3% of the US population) has reported specifically either being attacked or intimidated in a bathroom. Of the 40% or so of trans students who have dropped out of high school, most of them reported fearing for their physical safety or other bathroom worries.
Now — for the utilitarian calculation… Assuming the assertion that the majority supports this bill, the bill prevents no proven harms, but causes a lot of pain for trans persons. So, keeping the bill has a net decrease in pleasure, so it’s immoral to keep.
Notice, this isn’t “the greatest good for the greatest number of people” — which would end up favoring even some small perception of “good” (like perception of safety) for the “vast majority” of people supporting the law.