His mother died a few years later, in 1759, at the birth of the last of her daughters, Maria Giovanna; Even his father disappeared soon, in 1767.
Despite the economic difficulties, he succeeded in completing his legal studies and obtaining a modest seat in the Empolese tribunal.
In 1773 he finally went to Rome, where to host him was a well-known missionary in his hometown that convinced him to devote himself to ecclesiastical career.
He also gained the protection of Cardinal Ludwig Maria Torriggiani (1697–1777), who was able to become a student of "philosophical disciplines and sacred sciences" at the Roman College.
Meanwhile, Marchetti had become an assiduous guest of Pope Pius VI and, at Torriggiani's death, he was housed as secretary at the court of Giuseppe Mattei, Duke of di Giove (who was at that time the head of the horse-riding body of the Pontifical State).