This is one of those frustrating questions to which we may never find the definitive answer.
We know it means 'to give it all you have got', but the origin - from research and from answers submitted to us - is hotly disputed.
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.
Theories included the amount of material in a nun's habit; the length of a maharajah's ceremonial sash: the capacity of an ore wagon; the length of rope used in a hangman's noose; the distance between pitcher's mound and the hitter in American football. Probably all completely erroneous.
Hotly claimed but also seriously dubious is that it represents the capacity of an old-fashioned ready-mixed cement truck?!
Yards is a term for the long spars on a ship - so a three-masted ship would have three yards on each mast for the square sails, making nine in all. And thus a ship with all sails set would be using the whole nine yards.
Dubious because the phrase didn't become widespread until the 1960s - long long after three-masted ships.
And that dating issues also slighlty undermines our personal favourite - that in World War Two the machine gun belts in planes (Spitfires?) measured 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.