AT FIRST GLANCE, the attack launched Thursday by the Department of Justice against the advertising code of the television industry is incomprehensible. If it is successful, the limits most stations have agreed to impose on the amount of advertising they air will be gone. That makes it easy to conjure up visions of a 30-minute television hour - 30 minutes of programming interrupted by 30 minutes of ads. But, in fact, it is not clear the government lawyers are pursuing a wild antitrust theory that conflicts with the best interests of television viewers.

The television networks and most stations now adhere voluntarily to the limitations on advertising set out in the code of the National Association of Broadcasters. These say, among other things, that only 9 1/2 minutes of paid advertising should be put on the air during each hour of prime time and that 30 seconds and 60 seconds are the normal lenghts of ads. The code was created years ago at least in part because some responsible broadcasters feared that ads instead of programs would become television's main fare.

The department of Justice, say, however, that these limits are clear violations of the antitrust laws. They work, it say, to keep the cost of television advertising high because the numbers of ads that can be sold is restricted. This stops small companies from buying much time and tends to force consumer prices up because the bills paid by the giant advertisers are so large. This also makes television stations highly profitable.

It is quite possible - indeed, likely that the Justice Department is right in claiming the arrangement violates recent Supreme Court interpretations of the antitrust law. But if it is, the question raised by this case is whether the public will benefit more from a rigid application of the law than it does from the existence of the NAB's code. Obviously, the viewing public would not benefit from a substantial increase in the amount of television time devoted to advertising, regardless of what that did to the prices paid by the public.

But if the code is abolished, would the networks and individual stations react by increasing the numbers of ads they air and, presumably, lowering advertising rates? The government lawyers are guessing that some would and some wouldn't. There would always be the fear that too many ads would drive viewers to other channels. And there is always the possibility that once the existing arrangement on television advertising is broken up, new and better arrangements might develop. Open competition, as the recent experience of the airlines show, can change past practices dramatically.

At the heart of the government's case, however, is a more fundamental argument. If the NAB's code violates the antitrust law, should the Department of Justice wink at the violation? Or should it enforce the law and let Congress or the Federal Communications Comission grant an exemption if one is needed to protect television viewers against too much advertising? The FCC, of course, has always been the viewer's ultimate protection. It already has rules setting limits on advertising, which apply to those few stations that do not follow the more restrictive NAB code.