From "The Straight Dope":
SDSTAFF Dex replies:
It's difficult to know exactly where or how folksongs and folktales got started or exactly what they mean. "Sing a Song of Sixpence" is no exception. It appears as the third rhyme in Volume II of Tom Thumb's Pretty Song Book, published around 1744. No copy of Volume I is known to exist. There is only one known copy of Volume II, which is kept in the British Museum and is generally agreed to be the earliest existing book of nursery rhymes.
The rhyme appears in almost the same version that we have today, as follows:
Sing a Song of Sixpence,
A bag full of Rye,
Four and twenty
Bak'd in a Pye.
When the pie was opened,
The birds began to sing;
Was not that a dainty dish,
To set before the king?
The king was in his counting-house,
Counting out his money;
The queen was in the parlor,
Eating bread and honey.
The maid was in the garden,
Hanging out the clothes,
There came a little blackbird,
And snapped off her nose.
You will note a few changes since then, but not many.
The rhyme is almost certainly older than 1744, but no earlier publication has been found (at least, not as of 1970). There are earlier indirect references. Shakespeare, in Twelfth Night: "Come on, there is sixpence for you; let's have a song." And a 1614 work by Beaumont and Fletcher includes the line, "Whoa, here's a stir now! Sing a song of sixpence!"
According to the Oxford Dictionary of Nursery Rhymes, an Italian cookbook from 1549 (translated into English in 1598) actually contains a recipe "to make pies so that birds may be alive in them and flie out when it is cut up." The ODNR also cites a 1723 cook who describes this as an earlier practice, the idea being that the birds cause "a diverting Hurley-Burley amongst the Guests."
It was not uncommon in the 16th century for a chef to hide surprises in the dinner pie; this is also reflected in the nursery rhyme "Little Jack Horner" (of which more later). So the most obvious explanation of "Sing a Song of Sixpence" is that it reflected an actual practice--baking a pie full of live birds that popped out when the pie was opened.
Other theories include:
The 24 blackbirds reflect 24 hours in a day; the king is the sun, the queen is the moon. King Henry VIII is the king, Catherine of Aragon is the queen, and Anne Boleyn is the maid. The blackbirds are--get ready for this--manorial deeds baked in a pie. During the period when Henry VIII was taking over the property of the Catholic Church, the abbot of Glastonbury is said to have sent his steward to London with a Christmas gift intended to appease the king--a pie in which were hidden the deeds to twelve manorial estates. The steward, Thomas Horner, is alleged to have opened the pie and extracted one deed, that of the manor of Mells, where his descendents still live. This may be the origin of the aforementioned Little Jack Horner nursery rhyme. The song commemorates the publication of the first English bible, with the blackbirds being the letters of the alphabet set in pica type ("baked in a pie"). Personally My own uneducated opinion is that this interpretation is dubious, since the 24-letter alphabet only existed between the 10th and 11th Centuries. (W appeared in the 11th Century to condense UU, and J in the 15th Century as an initial form of I.) A few other explanatory notes, some courtesy of William S. and Ceil Baring-Gould, authors of The Annotated Mother Goose:
The "bag" in the 1744 version later became a pocket full, and it's presumed that a "pocket full" was once a specific measurement, like a cupful. Rye is, of course, a grain that was (and is) commonly used in bread making, or piecrust making, as the case may be.
The number four and twenty is among the most common in Mother Goose rhymes. It is twice twelve, or a double dozen. The number 12 brims over with tradition and associations. We have already described why the birds might be baked in a pie. The "counting house" was the place used to conduct business, and is referenced many times in Shakespeare's Merry Wives of Windsor. That pretty much explains the obscurer references; the rest of the rhyme is sort of self-explanatory. I shan't bother with explaining that "hanging up the clothes" was the way to let them dry after washing in the pre-Kenmore era.
By the way, some later versions of the rhyme include happier endings for the maid, such as:
They sent for the king's doctor,
Who sewed it on again,
He sewed it on so neatly,
The seam was never seen.
--SDSTAFF Dex Straight Dope Science Advisory Board
PLEASE NOTE: Snopes is a very reliable and wonderful source for debunking urban legends. However, the section of Snopes called "lost legends" starts with the warning that those "legends" require suspension of disbelief, and not letting "the truth get in the way of a good story." In short, those stories are false, they are made up, they are jokes. This includes the "piracy" origin of "Sing a Song of Sixpence" -- it is totally bogus, although quite amusing.