The decision is a blow to free speech and civil rights advocates, who have said such laws are discriminatory and lead to self-censorship in schools.