Many old sailing ships had three masts, the
- fore
- main
- mizzen
Each mast held three square sails. The horizontal stays that support the square sails are called yards. Hence the ships had nine yards.
Incidentally, a yardarm is one side of the yard.
Depending on the sailing conditions, more or less sails would be raised. In the best conditions peak speed could be achieved by raising all nine main sails, the whole nine yards.
Thanks to Harry Stevenson
COMMENT:
The whole nine yards does not refer to the sails of a ship but is the total length of standard width material needed to produce a mans suit including 2 waist coats