The windfall profits tax was pushed through Congress by the Carter administration to trap some of the earnings domestic oil producers were expected to reap when the price of domestically produced petroleum was decontrolled.

The tax was originally predicted to raise $227 billion for the government by 1990. With oil prices rising more slowly than Mr. Carter expected, windfall tax revenues have lagged behind projections: Last year, the tax yielded $14.5 billion. In the first six months of 1982, claims the Independent Petroleum Association of America (IPAA), oil firms paid about $5.3 billion in windfall profits taxes.

The IPAA filed the suit against the tax. Lloyd Unsell, IAPP vice-president, claims elimination of the windfall profits levy would have a ''minimal'' effect on the Treasury.

But the Congressional Budget Office projects the federal deficit will run in the area of $150-$160 billion through 1984. Eliminate the windfall profits tax, and the deficit would automatically get wider - increasing $24 billion, according to US government estimates made earlier this year.

The windfall profits tax is unconstitutional, ruled US District Judge Ewing Kerr in Cheyenne, Wy., because it is an excise tax that applies to all states except Alaska. Excise taxes, said Judge Kerr, must be uniform to be legal.

''Distinctions based on geography are simply not allowed,'' he wrote in his decision.

Alaska was exempted from the tax because much of its petroleum is difficult and expensive to reach. Therefore, says Jay Angoff, an attorney for the consumer group Congress Watch, the law doesn't discriminate in favor of Alaska as such. It favors a ''different kind of oil,'' he says, and is thus legal.

''I don't think (the decision) is anything to get too excited about,'' he says.

And government revenues won't immediately drop. Judge Kerr ruled that the Treasury should continue to collect the tax until a higher court has had the opportunity to judge the correctness of his ruling.