The Sumpreme Court ruled 5 to 4 yesterday that a state may not penalize an illegitimate child in order to induce the parents to marry or to promote "legitimate family relationships."

The court held that inheritance laws differentiating between legitimate and illegitimate heirs of parents who died intestate - without a valid will - "cannot be squared with the command of the equal protection clause" of the Constitution.

But in a 6 to 3 ruling affecting families separated by federal immigration laws, the court upheld preferences granted to legitimate alien children over illegitimate alien children.

The laws define an alien "child" seeking to enter the United States so as to exclude the illegitimate offspring of a father - but not a mother - who is an American citizen or a resident alien.

Similary, the state inheritance laws at issue allow an illegitimate child to inherit the estate of an intestate mother but not of an intestate father.

Justice Lewis F. Powell Jr. wrote the opinions for the court in both cases.

The inheritance case involved the Illinois probate act. It says that if an illegitimate child is to inherit the estate of an intestate father, the father must have married the mother after the child's birth and acknowledged paternity.

Other states have similar laws.

in the case at issue, the estate - a 1974 Playmouth valued at $2,500 - had belonged to Sherman Gordon, a Chicagoan who had lived with Jessie Trimble and their daughter Deta.

In 1973, a Cook County court ruled that Gordon was Deta's father and ordered him to pay $15 a week for her support. He complied, and he openly acknowledged her as his child. He was murdered in 1974, when he was 28.

If Deta had been a legitimate child or the named beneficiary in a will, she would have inherited the Plymouth. But the Illinois Supreme Court ruled her illegitimate under the probate law. And it upheld the law's constitutionality by relying in part on the state's purported interest in "the promotion of/legitimate/family relationships."

The immigration case involves three sets of unwed natural fathers and their illegitimate offspring, including Cleophus Warner, a naturalized citizen who petitioned the Justice Department for an immigrant visa for his son Serge, a citizen of the French West Indies.

The department denied the visa under a 1972 immigration law. A challenge to the constitutionality of the law was rejected by a panel of three federal judges in New York. The Supreme Court affirmed, saying it long has largerly immunized from jidicial control the government's power to expel or exclude aliens.