First of all, Monaco was annexed by revolutionary France and was part of it from 1793 to 1814.
Before 1793 and from 1814 to 1860 it was surrounded by lands belonging to the House of Savoy. (So for those specific timeframes, it would be pretty hard for France to annex Monaco without annexing Savoy's lands).
Monaco was surrounded by France from 1860 as a consequence of Treaty of Turin. Two years before, France had agreed to help the Kingdom of Sardinia (ruled by the House of Savoy) fight the Austrian Empire (Second Italian Independence War), and the price for this help was the Duchy of Savoy and the County of Nice.
Monaco was not annexed by Savoys before 1860, because its independence was guaranteed by France (Treaty of Peronne).
The later relation between Monaco and France was regulated by a treaty of 1861, when France guaranteed Monaco's sovereignty in exchange for the towns Menton and Roquebrune.
And why did France not try to annex Monaco? Maybe because Monaco is France's client state anyway: France controls its foreign affairs and may interfere with the succession issues, see Monaco Succession Crisis - so why annex it at all?
The other reason that comes to mind is that Monaco's existence as an independent state, attracting tourists and rich folks from all over the world, is beneficial to the whole South French Riviera economy, but this is a somewhat controversial statement.
And finally, addressing your question about the nationalism, if we only take a look at the languages: the Monagesque dialect is of Ligurian origin, but the local population through the time felt a rather strong local identity: during the revolution people threatened the Prince with establishing a republic, not joining France or Italy - in other words: it seems that the Monagesque people have never really desired to be a part of either France or Italy.