"Yankee Doodle" is a well-known Anglo-American song, the origin of which dates back to the Seven Years' War. The satirical verses were meant to entertain the British officers. It was sung by the British troops, as "Yankee Doodle" was a derogatory term for an American. According to the United States Library of Congress, when the Americans started winning the war, they appropriated the song and sung it proudly. An English doctor wrote the song during the French and Indian War in 1755.
This is a popular children's song, partly because of the goofy lyric, "Stuck a feather in his hat and called it macaroni." This lyric was meant to mock the fashion sense of Americans, as a "macaroni" was a term for a well-dressed man, and the line implied that Americans thought they could look good simply by sticking a feather in their hats. In the 1770s, a macaroni wig was an extreme fashion and "macaroni" became a contemporary slang term for a fashionable English dandy. So when Doodle puts a feather in his cap and calls it macaroni, it is a slap at the ragged bands of American troops.
This is the official state song of Connecticut. From 1950-2008 there was a famous coffee and sandwich shop in New Haven called The Yankee Doodle, known to locals (often Yalies) as "The Doodle."
Tradition has it that the words to at least one verse were originally written by British army surgeon Richard Shuckburgh in September 1775 at Fort Crailo New York, set to the "Doodle-doo" song from "The Beggar's Opera" by John Gay. The words were composed as Dr. Shuckburgh cared for the wounded and observed the disheveled, disorganized colonial raw American troops (called "Yankees" by the British) as they returned to Albany after the victory of William Johnson's army over the French at the Battle of Lake George.
Nowadays, we call silly drawings doodles, but back when this song was written, a doodle referred to a silly, incompetent person. The word most likely derived from the German term dodel, meaning fool.
Before you start imagining American troops slogging through swampland, a "swamping gun" has nothing to do with an actual swamp. The term swamping was early-American slang for huge.
One variation of the tune, explains Chris Roberts, author of Heavy Words Lightly Thrown: The Reason Behind The Rhyme, was used to help Yanks with their footwork. Roberts tells NPR: "It goes: 'Yankee Doodle, keep it up. Yankee Doodle, dandy. Mind the music and the step and with the girls be handy.' And this particular version was sung by predominantly the British as a reminder to our American friends that dance steps in Europe and in America, the colonies as it was, were different. And it's a reminder to check you doing the steps right and that you're holding the girl in the correct way."