"man who draws attention by unusual finery of dress and fastidiousness manners, a fop," c. 1780, of uncertain origin; attested earliest in a Scottish border ballad:
I've heard my granny crack
O' sixty twa years back
When there were sic a stock of Dandies O
etc. In that region, Dandy is diminutive of Andrew (as it was in Middle English generally). OED notes that the word was in vogue in London c. 1813-1819. His female counterpart was a dandizette (1821) with French-type ending.
Meaning "anything superlative or fine" is from 1786. As an adjective, "characteristic of a dandy, affectedly neat and trim," by 1813; earlier in the sense of "fine, splendid, first-rate" (1792) and in this sense it was very popular c. 1880-1900.
The popular guess, since at least 1827, is that it is from French Dandin, a mock surname for a foolish person used in 16c. by Rabelais (Perrin Dandin), also by Racine, La Fontaine, and Molière, from dandiner "to walk awkwardly, waddle." Farmer rejects this and derives it from dandyprat, an Elizabethan word for "a dwarf; a page; a young or insignificant person," originally (early 16c.) the name of a small silver coin. Both words are of unknown origin, and OED finds the connection of both to dandy to be "without any apparent ground." English dandy was itself borrowed into French c. 1830.
Jack-a-Dandy, or Jack O'Dandy figures in writings from the early 17c. He is listed among other famous Jacks in "Iack a Lent" (1620) and is sometimes defined as an impertinent little man, but other uses are unclear as to sense and in at least one instance from 1620s he is a bogeyman character.
DANDY was first applied half in admiration half in derision to a fop about the year 1816. John Bee (Slang Dict., 1823) says that Lord Petersham was the chief of these successors to the departed Macaronis, and gives, as their peculiarities, 'French gait, lispings, wrinkled foreheads, killing king's English, wearing immense plaited pantaloons, coat cut away, small waistcoat, cravat and chitterlings immense, hat small, hair frizzled and protruding.' [Farmer and Henley, "Slang and its Analogues," 1891]