It came from ...
An ENGLISH DRINKING SONG!!!
Although the words were written by American Francis Scott Key in the 19th Century, he borrowed the tune from The Anacreontic Song, a song celebrating Bacchinalian exploits which was such in the gentleman's club of the same name which existed in London during the 1700s.
Anacreon was a Greek poet who sounds a bit like yer standard pub singer who wrote and sang the usual 'wine, women and song' stuff in the tavernas of the 6th Century BC. Here's the chorus:
And besides I'll instruct you,
Like me, to intwine
The Myrtle of Venus
With Bacchus' Vine
It was often used as a sobriety test (in the days before Lion Alcometers! ;-)), if you could sing the whole verse in tune, then you were sober enough to order another round! A mite more difficult than '99 Bottles o' Beer'! The tongue-twisting tune was fiendishly difficult for a teetotaller, so you can imagine what it was like for a bunch o' bleezin Georgians!
Key's song and tune were adopted by the nation in 1931 as the national anthem, even though it had been used by the US Navy since 1889.
AND funnily enough, the previous anthem, 'My Country, Tis Of Thee' had been derived from God Save the Queen!
So, perhaps the best tunes belong to the old country! Still, I love it, it's fabulously patriotic and I defy most people not to want to belt out the last couplet! Keep on flying, star-spangled banner!
And the star-spangled banner in triumph shall wave
O'er the land of the free and the home of the brave!