It has to do with battle.
A ship-of-the-line of the late 16th to the middle 18th century always had three masts with three primary yards on each mast, the main yard, t'gallant yard and tops'l yards. In those days, and even into the early 19th century, it was rare for a ship-of-the-line to have any other yards. Even Admiral Nelson's flagship, HMS Victory, carried only nine yards in the Battle of Trafalgar, the last significant sea battle fought under sail.
For a sailing ship to complete a tacking maneuver, the attitude of the yards on the masts would be changed in a particular sequence. In the early stages of the tacking maneuver, the captain could change his mind and abort without any real consequence. However, once the ninth yard was changed over, attempting to abort would usually put the ship in stays (dead in the water, head to wind). And, as you might guess, that wasn't a good thing to happen.
In battle some captains would make use of this when maneuvering for position with an inexperienced opponent. They would start a tack to fake the opponent into a corresponding move. At the last moment, they would abort the tack to catch the opponent in a very weak position. A winning captain would always be watching his opponent's primary yards, knowing that the other captain wasn't fully committed to the maneuver until the he went with "the whole nine yards".
And, yes, I stole this from Google. My favorite search engine. Thanks again, Andrea, for the trivia!!
Once, you see, there was a very bad Scottish golfer named William who designed an entire golf course for the sun deck of a cruise ship. The only way he could get it to fit was to make the fairways very short and the greens small. When the new ship's captain asked William how long the 18th hole was, he replied, "The hole? Nine yards." Since this was a very historic statement, the cruise line credited William with the quote by placing a "w" at the beginning of the word 'hole.' Due to the great amount of publicity this received, it soon became a cliche. D:
If you're hoping for a definitive answer, you'd better buy a crystal ball. I have to say straight away this is one of the great unsolved mysteries of modern etymology, for which many seek the truth and almost as many find explanations, but hardly anyone
has a clue. What we do know is that the phrase is recorded from the 1960s, is an Americanism (it's nothing like so well known in Britain, for example), and has the meaning of "everything; all of it; the whole lot; the works". But there are no leads anyone can discover to a reasonable idea of where it came from.
What is most remarkable about the phrase is the number of attempts that have been made to explain it. This may be because it's an odd expression. But perhaps our need to make sense of this saying in particular is because it came into existence only during the lifetime of many people still with us, and so lacks the patina of age that turns phrases into naturalised idioms that we accept without question.
While looking into it, I've seen references to the size of a nun's habit, the amount of material needed to make a man's three-piece suit, the length of a maharajah's ceremonial sash, the capacity of a West Virginia ore wagon, the volume of rubbish that would fill a standard garbage truck, the length of a hangman's noose, how far you would have to sprint during a jail break to get from the cellblock to the outer wall, the length of a standard bolt of cloth, the volume of a rich man's grave, or just possibly the length of his shroud, the size of a soldier's pack, the length of cloth needed for a Scottish "great kilt", or some distance associated with sports or athletics, especially the game of American football.
None of these has anything going for it except the unsung inventiveness of compulsive explainers. For example, a man's suit requires about five square yards of material; anyone who thinks a soldier's pack could measure nine cubic yards is dimensionally challenged; and I'm told it takes ten yards to earn a first down in American football, not nine.
One particularly bizarre story that turns up more frequently than any other is that it represents the capacity of a ready-mixed cement truck, so that the whole nine yards might be a reference to a complete load. It does seem rather unlikely that a term from such a specialist field would become so well known throughout North America, but one or two writers are convinced this is the true origin. However, the capacity of today's trucks vary a great deal, and few of them can actually carry nine cubic yards of concrete. Matthew Jetmore, a contributor to the alt.folklore.urban newsgroup, unearthed evidence from the August 1964 issue of the Ready Mixed Concrete Magazine that this could not have been the origin: "Whereas, just a few years ago, the 4.5 cubic yard mixer was definitely the standard of the industry, the average nationwide mixer size by 1962 had increased to 6.24 cubic yards, with still no end in sight to the demand for increased payload". That makes it clear that at the time the expression was presumably coined the usual size was only about half the nine (cubic) yards of the saying.
This is probably what you're going for: Another relates to the idea of yards being the long spars on a ship rather than units of measurement. The argument is that a three-masted ship had three yards on each mast for the square sails, making nine in all. So that a ship with all sail set would be using the whole nine yards. The biggest problem here is dating - by the time the expression came into use, sailing ships were long gone; even if the phrase were fifty years older than its first certified appearance (unlikely, but not impossible), it would still be right at the very end of the sailing-ship era, and long after its heyday. Other problems are that big square-rigged sailing ships commonly had more than nine yards and that the expression ought in that case to be all nine yards rather than the whole nine yards (the same objection could be made about other suggestions that involve numbers rather than areas or volumes). Another attempt at relating the expression to sailing ships has it that nine yards is somehow related to the area of canvas, but a full-rigged ship had vastly more than nine square yards of sail.
Yet another explanation is that it was invented by fighter pilots in the Pacific during World War Two. It is said the .50 calibre machine gun ammunition belts in Supermarine Spitfires measured exactly 27 feet. If the pilots fired all their ammo at a target, they would say that it got "the whole nine yards". A merit of this claim is that it would explain why the phrase only began to be recorded after the War.
Some writers argue that the number isn't a dimension of any kind: Jonathon Green, in his Cassell Dictionary of Slang, suggests that it's most likely to represent a use of nine as a mystic number, after the fashion of nine tailors, the nine muses, and several other expressions; Jesse Sheidlower thinks that it may be related in this way to the number in the equally odd expression dressed to the nines.
What do I believe? I believe that, failing the discovery of the lexicographical equivalent of the crock of gold at the end of the rainbow, we are unlikely to find outthe truth about this one.