I am Italian, and this has always been of interest to me. It is a tiny, defenseless state surrounded on all sides by Italy.
I can understand why recently, with the establishment of a stronger framework of rules among countries, Italy has never tried to conquer San Marino. But why historically (according to San Marino they have been independent since 3 September 301) hasn't Italy tried to take it over?
Thank you.
I think a better question to ask is: Why didn't San Marino join Italy in the 1850s, like the other Italian states did, through plebiscites?
Why was an "Italian" nationalist ideal, not inculcated there, as it was in neighbouring states such as Modena, Tuscany, Romagna* (formerly part of Papal Land) etc.
Remember that 'Italy' is a fairly recent construct, for far longer it was a series of smaller states just sharing that peninsula. San Marino is actually the oldest sovereign country in the world at this point, pre-dating Italian unification by a huge amount of time.
Foreigners have also generally seemed to like San Marino, because of their perceived peacefulness and republicanism. Napoleon not only spared San Marino but offered to give them lands on the peninsula that he had conquered. San Marino declined, assuming somewhat perspicaciously that the other Italian States would want to retaliate in the future. In this way, San Marino was left largely to its own devices.
Edit: Spelling.
Italy was formed in three large tranches in a period commonly referred to as the Risorgimento. The first large annexation came in 1860 after Sardinia annexed a large portion of the States of the Church excluding modern-day Latium/Lazio, and the entirety of Parma, Modena, and Tuscany. Shortly after, Garibaldi led the Expedition of a Thousand and annexed the Mezzogiorno in 1861 and eventually proclaimed Victor Emmanuel as King of Italy. This brought about the Roman Question, or the question of whether or not Italy should annex the Latium region under the authority of the Church in lieu of making Florence the capital. The third major territorial acquisition was that of Lombardy and Venice, which was brought into the fold in 1866 after decades of Austrian domination in the region. Italy made its final (major) territorial acquisition in 1870 when the Roman Question was brought to an end and the Pope was required to hand over the keys to the Lateran Palace prompting Pius IX to utter "When Napoleon (I) invaded Rome, even he didn't have the guts to ask for the keys."
There would be further territorial acquisitions and losses, but none of these would be as significant as these three events.
San Marino is a small state governed by an executive body called the Captains-Regent. The Regents of San Marino aggressively pursued a policy of neutrality in foreign affairs, demurring on annexations of land and aggressive commercial policy. This led to their preservation in 1815 at Vienna and their later preservation in 1861 although this was to some degree accidental.
In 1850, as Garibaldi was in full retreat from the failed revolutions of 1848, he and his men sought refuge in San Marino. The Captains-Regent were initially wary although they eventually granted them clemency in exchange for a promise that they would never be brought into any larger Italian state or be obligated to support Garibaldi against the Great Powers. Garibaldi agreed and ultimately stopped the annexation of San Marino that nearly occurred in 1860, citing his earlier promise to the Captains-Regent in 1850. The Savoys and the Italian Parliament were occupied with far greater matters than the annexation of a state the size of Central Park and thus promptly agreed to Garibaldi's strange request in order to focus on larger events. San Marino was therefore left alone in peaceful neutrality to pursue its own affairs by virtual accident.
FYI, you'll find a few relevant posts in the FAQ. The posts have been archived, so if you have follow-up questions, ask them here, and include the relevant user's username to notify them.