MARGARET RANDALL has a complicated immigration history, and the U.S. government is making a perfect fool of itself in dealing with it. You would think she had the bomb.

Mrs. Randall was born in New York but moved to Mexico during the '60s. Twenty-one years ago she walked into the U.S. Embassy in Mexico City and signed an affidavit renouncing her American citizenship. Later, she lived in Nicaragua and Cuba and visited North Vietnam, and she has written extensively in praise of these countries. In 1984, she returned to the United States -- her parents and brother live here and her four children are Americans -- and she would like to stay permanently. Because she is no longer an American citizen she must apply for permanent residence just like any other would-be immigrant, and because her close relatives are Americans this would not ordinarily pose a problem.

Unfortunately for Mrs. Randall and for many others, however, U.S. law prohibits the entry into this country of aliens "who write or publish . . . knowingly circulate, distribute, print or display . . . or have in their possession for the purpose of circulation, distribution or display, any written or printed matter . . . teaching the economic, international and governmental doctrines of world communism or the establishment in the United States of a totalitarian dictatorship." Notice the verbs: write, publish, circulate, teach. These are acts clearly protected by the First Amendment in the case of American citizens. But aliens do not have that protection, and since Mrs. Randall is technically an alien, immigration authorities have ordered her deported on the basis of her earlier writing. That decision is on appeal, as is an adverse ruling by the U.S. district court here.

The law is not just an anachronism, it is a disgrace. Much of officialdom recognizes that. The State Department has urged its modification, and Congress, in the closing days of the last session, adopted a provision authored by Sen. Daniel Patrick Moynihan eliminating this test for visas during 1988. Permanent legislation is expected later this year. Shouldn't this solve the problem for Mrs. Randall? No, because the Immigration and Naturalization Service takes the position that the Moynihan provision applies only to applications for visitors' visas -- not to those leading to permanent residence. Mrs. Randall's attorney, David Cole, points to clear language in the conference report indicating that Congress intended the provision to apply to all applications, but the foolish litigation drags on.

The case ought to be dropped. Mrs. Randall made a terrible mistake in giving up her citizenship. She concedes as much. But the penalty for her bad judgment and her fatuous political views is out of all proportion. She has never committed a crime, and her writings pose no threat to the republic. The INS, you would think, has enough to worry about these days without fighting this losing battle through the courts.