There are no official criteria, but a pope usually chooses to honor a predecessor or someone he admires. For example, John Paul II honored Paul VI and John Paul I, and John XXIII honored his father. He may also choose to give an indication of the course of his papacy, as did Pius XII, who indicated that he would continue Pius XI’s work.
There are no restrictions on the choice of name, but it is an unwritten custom that popes do not choose the name Peter. It is generally considered a matter of prudential judgment for popes not to invite comparisons between themselves and the pope Christ himself chose.