Dressed flamboyantly or smartly.
Nine is, without doubt, the most troublesome number in etymology. Phrases of uncertain parentage that include 'nine' are 'cloud nine' and the infamous 'whole nine yards'. To those we can add 'dressed to the nines'.
Numerous attempts have been made to associate the number nine with clothing and so to explain the phrase's derivation. One theory has it that tailors used nine yards of material to make a suit (or according to some authors, a shirt). The more material you had the more status, although nine yards seems generous even for a fop. Another commonly repeated explanation comes from the exquisitely smart uniforms of the 99th (Lanarkshire) Regiment of Foot, which was raised in 1824. The problem with these explanations is that they come with no evidence to support them, apart from a reference to the number nine (or 99, which seems to be stretching the cloth rather thinly). The regiment was in business in the early 19th century, which is at least the right sort of date for a phrase that became widely used in the middle of that century. The first example of the use of the phrase that I can find in print is an extract from the New York Herald, 1837:
"One evening a smart young mechanic, 'dressed to the nines', as Ben Bowline says, might have been seen wending his way along Broadway."
What counts against the above explanations, and indeed against any of the supposed explanations that attempt to link the number nine to some property of clothing, is the prior use of the shorter phrase 'to the nine' or 'to the nines', which was used to indicate perfection, the highest standards. That was in use in the 18th century, well before 'dressed to the nines' was first used, as in this example from William Hamilton's Epistle to Ramsay, 1719:
The bonny Lines therein thou sent me,
How to the nines they did content me.
It is worth noting that the number nine has long been used as a superlative. Classical mythology gave us the Nine Muses of Arts and Learning. The Nine Worthies were characters drawn from the Pagan and Jewish history and from the Bible. This distinguished group consisted of Hector, Alexander, Julius Caesar, Joshua, David, Judas Maccabaeus, King Arthur, Charlemagne, and Godfrey of Bouillon.
The Nine Worthies, usually called simply The Nine, were well-known to mediaeval scholars as the personification of all that was noble and heroic. The Poetick Miscellenies of Mr John Rawlett, 1687, provides the earliest reference to 'to the Nine' that I can find:
The learned tribe whose works the World do bless,
Finish those works in some recess;
Both the Philosopher and Divine,
And Poets most who still make their address
In private to the Nine.
It seems clear that 'the Nine' that Rawlett was referring to were the Nine Worthies. It is just as clear that 'dressed to the nines' is merely an extension of 'to the nine/s' and that we could equally well say 'danced to the nines' or 'embroidered to the nines' to appreciate good dancing or embroidery. It isn't surprising that the search for the link between 'nines' and dress sense has unearthed no convincing candidates - call off the dogs; there is no such link.