A tentative decision by Attorney General Griffin B. Bell to replace the U.S. attorney in New Jersey has raised fresh questions about the firmness of President Carter's pledge to divorce the government's legal machinery from politics.

In legal circles extending well beyond New Jersey, the case of U.S. Attorney Jonathan Goldstein is being viewed as potentially the most revealing test to date of how serious Carter is about the promise that he made during his election campaign.

"All federal judges and prosecutors should be appointed strictly on the basis of merit, without any consideration of poltical aspect or influence," he said last year.

It's statement that since has been coming back to haunt Carter and Bell with embarrassing frequently.

First, the Senate made clear it wasn't about to surrender its patronage power over the naming of U.S. District Court judges - an attitude that caused Carter and Bell to hastily rethink their ideas about having the judges picked by independent citizens' panels.

Now, the gap between the administration's promise and performance is being exposed to scrutiny in the equally sensitive appointment of U.S. attorneys.

New Jersey has taken on the status of a test case in this repect because Goldstein is the lastest in a succession of Republican-appointed U.S. attorneys there who have won national prominence for prosecuting organized crime and political corruption.

Goldstein is not universally admired. A lot of people, including powerful members of the state Democratic Party, want him out. Two leading New Jersey Democrats, Sen. Harrison A. Williams Jr. and Rep. Peter W. Rodino Jr., chairman of the House Judiciary Committee, have submitted the names of several candidates they'd prefer to see in the job.

But Goldstein also has remarkably broad-based support form legal, business and community leaders within New Jersey. This support also crosses the state's borders to inclusde many permanent voices in national law enforcement circles and a sizable number of the Justice Department's career attorneys.

That poses a sticky problem for the administration, which last month found itself embroiled in a noisy controversy over Bell's firing of the Republican U.S attorney in Detroit, Philip Van Dam, who had announced his refusal to resign.

Van Dam's parting shot was to charge that the president was playing "politics as usual" and said, "He's as goddamned hypocritizal as anyone else before him."

That charge wasn't exactly laid to rest by Bell, who said of Van Dam's firing: "The main reason is that we had an election last November, and the Democrats won. You can use your imagination after that."

Despite Bell's statement, his top aides at the Justice Department insist that a genuine attempt is being made to move toward a merit system in the selection of U.S. sttorneys. Associate Attorney General Michael J. Egan, who heads this effort, says Carter and Bell regard these positions as among the most important in government and are deeply committed to filling them with the best people available.

However, Egan, who is a Republican, candidly admits that politics and party affiliation are still playing a big role in determining who gets the jobs.

"Sure," he says, "these appointments ideally should be made purely on the basis of ability and achievement, without even asking whether the man's a Democrat or Republican. But the time for that has not yet come, and it won't until there's a change in the perceptions of the Senate."

So, he says, Carter and Bell have been trying to work within the limits of that political reality by promulgating a rule that he states in this way: "Before we will replace an incumbent U.S. attorney at the request of a senator, he must give us an alternative candidate who is as good or better."

When Bell entered office, he invited all incombent U.S. attorneys who wanted to stay on to advise him of their desires, and he promises them careful consideration for retention.

That, Egan insists, was not an empty promise.

He notes that there has been no mass purge in the ranks of the 94 U.S. attorneys around the country. Instead, the Carter adminstration so far has chosen only about 20 new ones, and Egan says a number of incumbents will be kept.

That was the case in New York where Sen. Daniel P. Moyniban (D-N.Y.) recommended that three Republic-appointed incumbents be retained. "All had records of high-grade performance," Egan says, "and we were happy to keep them."

Still, that doesn't answere the question of what happens in a state like New Jersey, where the Democratic senator isn't so obliging and the administration finds itself under pressure to replace someone with Godstein's reputation for non-political effectiveness.

Bell said publicly last week that Goldstein, probably will be replaced. If that happens, there's certain to be an outcry from Goldstein's supporters about merit being sacrificed for partisan considerations.

However, the administration has moved to guard its flanks by insisting to Williams and Rodino that their candidates have sufficiantly strong credentials to counter charges that the job is going to someone inferior.

While various interest groups in New Jersey have voiced objections to certain of the people under consideration, one knowledgeable New Jersey political observer says of the Williams and Rodino nominees, "They're all very respectable lawyers."

Egan contends that the same can be said for all the nominees chosen so far by thd Carter administration Although most have clearly identifiable Democratic ties, they come from a variety of legal backgrounds.

Some, like Thomas P. Sullivan in Chicago, are well-established lawyers with high-powered private practices and impressive records of civic and public legal service. Others have more overtly political backgrounds, like George J. Mitchell, who was an unsuccessful candidate for governor of Maine.

There are legal scholars like Frank F. Tuerkheimer, a professor at the University of Wisconsin law school, and Justice Department alumni like Edward F. Harrington, former head of the New England Organized Crime Strike Force who has been tabbed by Sen. Edward M. Kennedy (D.Mass.) for the Boston office.

And some, like Richard Blumental, who is slated to take over in Connecti-cut at the age of 31, are people whose credentials of academic achievement and careers to date show promise of making them the movers and shakers of the legal community a few years down the road.

"If you're talking about merit," Egan insists, "we think the people we're naming will pass muster against anybody's set of standards."