The Supreme Court ruled 5 to 4 yesterday that a state may refuse to employ aliens to teach in elementary and secondary schools if they are eligible for but don't seek citizenship.

A teacher "has an opportunity to influence the attitudes of students toward government, the political process, and a citizen's social responsibilities," Justice Lewis F. Powell Jr. wrote for the majority. "This influence is crucial to the continued good health of a democracy."

Upholding a New York State statute, Powell said that its citizenship requirement for public school teachers "bears a rational relationship to a legitimate state interest" and thus complies with the Constitution's guarantee of the equal protection of the laws.

In the dissenting opinion, however, Justice Harry A. Blackmun termed the New York requirement "irrational" saying:

"Is it better to employ a poor citizen-teacher than an excellent resident alien teacher? Is it preferable to have a citizen who has never seen Spain or a Latin-American country teach Spanish to eight-graderss and to deny that opportunity to a resident alien who may have lived for 20 years in the culture of Spain or Latin America?

"The state will know how to select its teachers responsibly, wholly apart from citizenship, and can do so selectively and intelligently. That is the way to accomplish the desired result. An artificial citizenship bar is not a rational way."

Concurring in Blackmun's opinion were Justices William J. Brennan Jr., Thurgood Marshall and John Paul Stevens.

Starting in 1886, the court gradually has restricted the activities from which a state could exclude aliens. But in what was widely regarded as a sharp departure from this trend, the court 13 months ago upheld a New York State law requiring state troopers to be citizens.

Just as a "rational relationship" exists between the police function and a citizenship requirement, so does it exist between the public education function and the same requirement, Justice Powell wrote. A state "properly may regard all teachers as having an obligation to promote civic virtues and understanding in their classes, regardless of the subject taught," he said.

Each of the two teachers in the case has been in the United States for at least 12 years, is married to an American citizen, pays taxes, and is willing to take an oath to support the federal and state constitutions-but is unwilling to give up British or Finnish citizenship.

Blacmun said it is "logically imposible" to explain why the same court that says it's permissible to keep such resident aliens out of the classroom said in 1973 that a state may not constitutionally prevent similar resident aliens from taking bar exams and practicing law.

"One way speak proudly of the role model of the teacher. . . and of his profound influence in the impartation of our society's values," he said. "Are the attributes of an attorney any the less? He represents us in. . . critical courtroom controversies even when citizenship and loyalty may be questioned. . . he, too, is an influence in legislation, in the community, and in the role model figure that the professional prerson enjoys."