The origins of "Yankee" have been fiercely debated throughout the history of the Republic, and to this day the Oxford English Dictionary says the source of the word is "unascertained." Perhaps the most widely accepted explanation was advanced by H.L. Mencken, the well-known newsman-scholar (and don't tell me that isn't an unusual combination), who argued that Yankee derives from the expression Jan Kaas, literally "John Cheese." This supposedly was a derogatory nickname bestowed on the Dutch by the Germans and the Flemish in the 1600s. (Wisconsin cheeseheads can undoubtedly relate.)
The English later applied the term to Dutch pirates, and later still Dutch settlers in New York applied it to English settlers in Connecticut, who were known for their piratical trading practices. During the French and Indian War the British general James Wolfe took to referring derisively to the native New Englanders in his army as Yankees, and the term was widely popularized during the Revolutionary War by the song "Yankee Doodle." By the war's end, of course, the colonists had perversely adopted the term as their own. Southerners used Yankee pejoratively to describe Northerners during the Civil War, but found themselves, along with all other Americans, called thus by the English during world wars I and II.
-straight dope