In a modern-day saga reminiscent of David vs. Goliath, William Hamilton has battled the Justice Department for eight years in an epic legal dispute that has haunted two attorneys general.

Hamilton and his wife, Nancy, own Inslaw Inc., a small computer software developer. Two federal judges have ruled that the Justice Department stole the company's valuable software - called "Promis" - and then tried to use the bankruptcy process to put Inslaw out of business.A newspaper columnist has dubbed the Inslaw case the "scandal that will not die."

A fifth federal judge now presides. Hamilton says his legal bills are "in excess of $6 million." But he is determined to press on, citing his Irish temperament.

Hamilton has calculated Inslaw's lost profits from the pirated software at $300 million - and rising.

A congressional committee is investigating. But Attorney General Dick Thornburgh has refused to turn over Justice Department documents, provoking an increasingly bitter dispute with Rep. Jack Brooks, D-Texas, chairman of the House Judiciary Committee.

A senior Justice Department official told United Press International that the agency was close to an agreement allowing congressional investigators to examine the 200 documents. Negotiations over the "ground rules" were continuing.

New affidavits filed by Inslaw charge that former senior White House aide Robert McFarlane transferred the stolen software to Israeli officials. Another affidavit states that a former Justice Department official threatened retribution against a witness if he cooperated with congressional investigators.

Also, according to the new charges by Inslaw, Richard Secord, a former Air Force major general who pleaded guilty in the Iran-Contra scandal, played a role in the Inslaw affair.

Inslaw also has charged that U.S. businessman Earl Brian is a central figure in the case. Brian, a friend of former Attorney General Edwin Meese, is a principal in a bankrupt holding company, Infotechnology Inc.

After President Reagan nominated Meese as attorney general, an investigation by an independent counsel disclosed that Meese had failed to report his wife's investment in two companies controlled by Brian and had failed to report a $15,000 loan from a subordinate who was a close Brian friend.

The Justice Department has continued to appeal. Inslaw, meanwhile, is represented by a heavyweight - former Attorney General Eliot Richardson.

Richardson says Justice Department officials conspired to steal the software program - now believed to be worth some $200 million - and deliver it to Brian's computer outfit, Hadron.