A new book by priest-sociologist Andrew Greeley asserts that the last three popes have tried unsuccessfully to remove Cardinal John Cody from his post as archbishop of Chicago.

According to Greeley, Pope John Paul I "had given orders for the replacement of Cardinal Cody. The papers of the Cody case were in his hands when he died."

Similarly, writes Greeley in his new book, "The Making of the Popes 1978," both Pope Paul VI and Pope John Paul II attempted to remove Cody from Chicago by offering him Vatican posts.

Critics of Cody, who has headed the Chicago archdiocese since 1964, have alleged that he has failed to implement many of the changes mandated by the Second Vatican Council and that the archdiocese, the largest in the nation, is badly administered.

Last month the Association of Chicago Priests took the uprecedented step of voting to send two men to Rome to plead with the Vatican to remove Cody, who will not reach the retirement age for Catholic bishops until 1982.

The Chicago prelate has categorically denied Greeley's assertion that he had rejected papal requests to step down.

Greeley is a syndicated columnist as well as a staff member of the Carter for the Study of American Plurilism at the National Opinion Research Center at the University of Chicago. He is a priest of the Chicago archdiocese.

In his book, scheduled for publication next month, Greeley declares that the Chicago cardinal "has successfully played the Polish ethnic card to frustrate attempts by responsible church officials to remove him."

He said that after the election of the present pope, "Cardinal Cody parlayed his past financial contributions to Poland . . . the size of the Polish population in Chicago, and his alleged friendship with the pope into a successful counteroffensive against his enemies. John Paul II, according to what the cardinal told visitors in early December, merely offered him a job in Rome, which he declined. The pope, has cardinal intimated, indicated that the matter was thus closed."

In the foreword to his book, which he acknowledged in modeled on author Theodore White's volumes on presidential elections, Greeley says he had followed the rule of "not including allegations which could not be confirmed by two independent sources."