Mhairi is the vocative case of the name Mairi.
It's pronounced VAR-ee.
The name itself is pronounced MAR-ee.
In Gaelic and Irish (Gaeilge), nouns change spelling and pronunciation according to case -- nominative / accusative (the basic noun), possessive / genitive (when the noun owns something), vocative (when you address a person by their name), and prepositional / dative case (when the noun is positioned).
Nouns come in masculine or feminine form, and are also changed by number.
The name "Mhairi" came about because non Gaelic speakers saw the spelling of the vocative case of Mairi and thought it was cute and quintessentially Scottish. The name itself is Mairi, pronounced MAR-ee. If you were speaking Gaelic and were addressing someone called Mairi, you would start your conversation with "A Mhairi..." ("A VAR-ee..."), using the vocative form to address her.
The same process of ignorant mixing of cases occurred for the name Hamish, which is a transliteration into English of the vocative case of Seumas (Scots Gaelic version of James).
In the vocative case, names that start with any letter apart from L and (iirc) R add an H after the initial consonant, which changes the pronunciation of the consonant. Mh and Bh become V, Sh becomes H, Th becomes H, Gh becomes a very soft G sound where the back of the tongue doesnt quite touch the palate at the back of the mouth, D becomes almost the same sound as Gh but closer to a Y sound, etc...