The judge didn’t say, “to keep from offending others”; he said, “to prevent ... invading the rights of other students.” Then he specifically said that he did not recognize a “right” to not hear something you didn’t like.
I assume what he had in mind was “invading” another student’s “right” to learn the subjects being taught in school. For example, if one student spend the entire class period screaming obscenities at everyone else, that prevents the educational mission of the school from progressing. In that situation, I think everyone would agree the student should be removed.
Sad, though, that many (mostly liberals) need remedial training in the understanding of free speech. I am reminded of the student demonstrator attempting to shout down the speech of someone he disagreed with. As he was led away, he was heard to shout, "My free speech rights are being violated!"
You post an excellent example of the abuse, not misuse, of free speech rights.