And now a bit of history. First of all, you should know that the popes didn't always live in the Vatican: for many centuries their residence was the palace next to the Archbasilica of St. John Lateran. In the 1300s, the papal headquarters were temporarily transferred to Avignon, in Southern France. Once they returned to Rome, Pope Gregory XI decided to move the pope's living quarters from St. John Lateran to the Vatican on the other side of the Tiber River. The papal palace was quite simple at that time, in a less populated area, but it had the advantage of being protected by the ancient city walls.
Thanks to Pope Nicholas V and in preparation for the Jubilee of 1450, the Vatican Palace started to become a reference point for architects and artists. A precious record from this period is the chapel frescoed by Fra Angelico in the immediate vicinity of the Raphael Rooms. 25 years later, the Apostolic Library (which was renovated and enlarged at the end of the 16th century) and the Sistine Chapel were built: from that point on, the Vatican construction site became the most important center of Renaissance art. The popes of these years competed to decorate it: Alexander VI had frescoes painted in his apartment by Pinturicchio (whose halls host the collection of modern religious art today, included at the behest of Paul VI), Pope Julius II entrusted the palaces' general refurbishment to Bramante with the Cortile del Belvedere, the great niche in the Cortile della Pigna, and the Cortile di San Damaso, and Leo X had the third courtyard frescoed by Raphael. And that's not all: Pope Paul III had the Pauline Chapel added, which was frescoed by Michelangelo, and in the mid-1600s Bernini designed the new Library and Scala Regia, the monumental staircase connecting the atrium of St. Peter's Basilica to the Vatican Palaces.
Starting in the late 1700s, the papal palaces were gradually transformed into a museum. The first collections were mainly devoted to archaeology and they were (and mostly still are) named after the pope who established them. In many cases, the popes issued edicts and measures to protect artistic heritage, significantly before any other nation in the world did so.
FUN FACT: in 1938 Adolf Hitler visited Rome and was hosted by the King and Mussolini. Pope Pius XI did not want to welcome him, and to avoid doing so he left for Castel Gandolfo. But above all, and unprecedented, he closed the museum and basilica to all visitors. Thus Hitler couldn't even set foot in the Vatican.