Partially because size does not determine a nation’s sovereignty. There’s a whole category of states called micronations that exist usually within the borders of a larger country. Sometimes their independence is disputed but it’s mostly down to the will of the citizens versus that of the parent country to control them.
Vatican City is a renewed version of the old Papal States.
Italy is a fairly new country. Prior to Italian unification, there were several Italian states, such as Venice, Florence/Tuscany, Naples, etc. The Papal States, with Rome as the capital and Pope as its leader, was one of those states and founded around the 8th century. In the 1860s and 1870s, the newly unified Kingdom of Italy pretty much annexed all of the Papal States. The Pope however remained in St. Peter’s Basilica in Rome and refused to surrender to Italy. For nearly 60 years, the Pope was a quasi-prisoner in Rome who often spoke out against the Kingdom of Italy. The various popes basically encouraged all Catholics to refuse to accept Italy as a country. In the 1920s, Mussolini took control of Italy and tried to resolved this issue with the Pope. In the 1929 Lateran Treaty, Mussolini gave the Pope his own country (the Vatican) in return for the Pope’s support of his regime. Vatican City has remained a sovereign state since then.
Vatican City is the seat of the Catholic Church. Just a very wealthy microstate now, but once the center of power in Western Europe through the Middle Ages and into the early industrial era.
One doesn’t simply attack *the pope* during the height of his power, attempting to do so would risk igniting a holy war if greater Catholicism didn’t approve of whoever is attempting to consolidate power over Italy.
That’s not to say these things didn’t happen – the Vatican was indeed attacked several times over the centuries – but it has a strong historical tendency towards being an independent religious state free from the whims of kings that ruled by the Pope’s blessing.
In theory the pope approves the Catholic kings, not the other way around.
Visibility on a map has no bearing on whether a territory would be recognized as independent from other recognized nation-states. For that you need political capital.
Vatican city, as the residence of the Pope, and pillar of catholic authority, has had ample supply of political capital through the formative centuries of European development. Though it probably has less power now, the sheer weight of institution, along with the personal value of hundreds of millions, if not over a billion people around the world, so give it a measure of authority. Any country so inclined faces steep international backlash should they wish to annex Vatican city unwillingly, and why would the Vatican give up their independence willingly?
Before Italy was unified, it was made up of several mostly independent states – the Papal States were a large chunk of Italy, and were actually controlled by the Pope from Rome. Italy as we think of it today just wasn’t a thing for most of its history. In the 1800’s, many of those states decided to unify, becoming more-or-less what we think of as “Italy” today, but the Pope didn’t like the idea of losing power – there’s a lot more to that story, but at the end of the day, the new “Kingdom of Italy” took over the Papal states and most of Rome – they just left the Pope a little section on Vatican hill, where he called himself a “prisoner.”
The new Italian army didn’t want to take over that last section and risk the rest of Europe (or at least, all of their Catholics) declaring war on them, so they mostly left the next few Popes go about their business, but there was still a lot of political tension there. Italy considered the Vatican (and the Pope) to be Italian, but they gave the Pope a lot of special powers, while the Popes (there were several new ones elected throughout this period) considered themselves prisoners of an illegitimate government that stole all of their land.
Eventually, in 1929 with the Lateran Treaty, they came to an agreement. Vatican City was allowed to become its own independent state, Italy paid them back for the land that they “stole” in the unification, and some other agreements between Italy and the Church. So since then, Vatican City has been its own independent enclave, run by the Holy See, the Pope and the many other people that are appointed to run the church and the city.
In addition to what has been said, Italy has sworn to protect the Papal states from invaders, so they are a state that has even fewer attributes that one would ascribe to a sovereign state.
Bear in mind that the Holy See was EXTREMELY political in the earliest days, and has gradually lost direct jurisdiction over former “Catholic lands”. The organization remains politically involved in a nuanced way, but it has decided to market itself in a more spiritual light than its former political one (they didn’t even have that many doctrines until the Reformation convinced them to specify out of spite).
They found out how to remain influential without burning people at the stake, and that is by “spiritually” persuading millions of grandmas to fork over a segment of their fixed income, and pressuring their kids to propagate as much as possible and to baptize their young, and put the Catholic yoke on their neck with a spiritual fear in all of them, never giving them assurance of salvation. This, they hope, will make Rome fat and jolly with additional wealth, and it does.
Because it is such a wealthy entity and due to the fact that Italy basically functions as its military, because thousands of people dangle rosaries in their hands and are ready to do the bidding of Rome, and the fact that it [arbitrated between Argentina and Chile in a border dispute](https://www.nytimes.com/1978/12/24/archives/argentina-and-chile-accept-papal-effort-in-dispute-45000-chilean.html), I would say they are transcendent of states since they have a monopoly on certain minds as opposed to direct political hierarchies of foreign states.
You ask “why the Vatican is independent?”, but I ask “who is independent of the Vatican?”
Latest Answers