With its decision last week in the case of a high school newspaper in Missouri, the U.S. Supreme Court restored a degree of sanity to an area of the law that had been threatened by lower court lunacy. It was a welcome decision. Heaven knows it had been a long time coming.

What are the constitutional rights of students in public schools? The high court has grappled with that question off and on for the past 20 years. Lower federal courts have worried incessantly over the issue. A few years ago a professor at Ball State University compiled a list of 1,200 cases involving student expression. In the overwhelming majority, the students had won and school officials had lost.

Last week the worm turned. The circumstantial details in the case were a little complicated, but these were the essential facts. Hazelwood East High School in St. Louis County, Mo., maintains a class called Journalism II. As part of their classwork, students prepare a more-or-less monthly newspaper called Spectrum. The teacher names the editors, makes story assignments, decides the number of pages, selects and edits letters to the editor and otherwise functions in the role of a managing editor. Prior to publication, the teacher submits page proofs to the principal for approval. About 80 percent of Spectrum's costs are paid from public funds; the balance comes from sales of the paper.

In May 1983, at a time when one teacher of Journalism II had resigned and a newcomer had taken charge, student staffers prepared two touchy articles for Spectrum's final issue of the year. One dealt with teen-age pregnancies, the other with the impact of parental divorce. Hazelwood's principal killed both stories. He objected that the piece on teen-age sex might invade the privacy of the girls who were interviewed, even though their names were not used. Besides, he thought the story unsuitable for younger students. He viewed the piece on divorce as unfair and one-sided.

The student authors sued the school officials in federal court, charging that their First Amendment rights to freedom of the press had been violated. They lost in the trial court but won on appeal to the Eighth Circuit. The school then appealed to the Supreme Court. Last week the students suffered a stunning defeat and school principals won a ringing victory.

Speaking through Justice Byron White, the court held flatly that school officials have power to regulate student newspapers ''in any reasonable manner.'' Said White: ''We hold that educators do not offend the First Amendment by exercising editorial control over the style and content of student speech in school-sponsored expressive activities so long as their actions are reasonably related to legitimate pedagogical concerns.''

A public school, the court held, ''must be able to set high standards for the student speech that is disseminated under its auspices . . . and may refuse to disseminate student speech that does not meet those standards.'' This means that students have no constitutional right to publish material in a school-sponsored newspaper (or theatrical production) that is ''ungrammatical, poorly written, inadequately researched, biased or prejudiced, vulgar or profane, or unsuitable for immature audiences.'' In brief, a high school principal functions in the capacity of publisher of a newspaper or producer of a play. His word in these regards is final.

White's opinion is completely consistent with the court's holding in the Tinker case of 1969 and the Fraser case of 1986. Tinker involved several children in Des Moines, Iowa, who protested the war in Vietnam by going to school, in defiance of a regulation, with black armbands on their sleeves. They were suspended, but the Supreme Court upheld their right so to express their individual views. The armbands were no part of the school's curriculum. The Fraser case involved a brash youngster at the Bethel (Wash.) High School who made a ''lewd and indecent'' speech at a school convocation. He was briefly suspended. The high court upheld the suspension. The speech had been made as part of an official school program.

Nineteen years ago, Justice Hugo Black dissented in the armband case. He thought the conduct of the Tinker children ''disruptive.'' He saw no constitutional reason why the nation's public schools should be subject ''to the whims and caprices of their loudest-mouthed, but maybe not their brightest students.'' It is a myth, said Black, ''that any person has a constitutional right to say what he pleases, where he pleases and when he pleases.'' It is a lesson worth teaching in Journalism II.