Sketching the musical history of "My Country 'tis of Thee" is relatively easy, but fleshing out the details of this history is more difficult. Certain pieces of the story are clear; Lyricist Samuel Francis Smith was introduced to the tune while working with a German songbook in 1832. He liked one melody in particular because it had a patriotic feel, so he wrote the words that we now sing.
Smith said that he did not know that the tune that intrigued him was used much earlier for "God Save the Queen/King," Great Britain's national anthem, but that didn't stop almost everyone else from quickly recognizing the familiar melody. "God Save the Queen/King" had been a patriotic favorite in England since the 1740s and had circulated in North America since at least the 1760s.
The melody's origins are more difficult to trace beyond this point. Some music historians have argued that German composer George Frideric Handel wrote the basic tune some time before 1720. One can hear the familiar tune within the "Sarabande" from his Suite No. 4. Others have argued that the British anthem had British roots. Several works by 17th century English composer Henry Purcell are frequently cited as the origins of "God save the Queen/King." Another group claims that the song is even older, derived from a Scottish song, or even from an early Catholic liturgical plainsong.
Don't you just wish they kept better records of this stuff back then? Or at least didn't go around pretending they'd never heard stuff?