Inspired by the question How long is a 'wink'?, I did some work on the origin of the phrase forty winks. Though the OP at the wink question mentions the phrase, it does not ask about its origin. So I thought I'd ask the question here and post what I've found. I was able to find an antedating not mentioned by any of the usual phrase-dictionary suspects. The most accurate information I found elsewhere was from a post by Ken G in a discussion of the phrase at Wordwizard. Any other insights welcome.
William Kitchiner M.D. (1775–1827) was an optician, inventor of telescopes, amateur musician and exceptional cook. His name was a household word during the 19th century, and his Cook’s Oracle was a bestseller in England and America.
The phrase forty winks, meaning a short nap, can be traced back to Dr. Kitchiner's 1821 self-help guide, The Art of Invigorating and Prolonging Life. The phrase is mentioned in a November 1821 issue of the British Literary Chronicle, in a review of Kitchiner's book:
Sleep is a subject on which our author acknowledges his feelings are tremblingly alive; he is fond of a 'forty-winks' nap in an horizontal posture,' as the best preparative for any extraordinary exertion, either of body or mind.
Here is a clip from an 1822 copy of Kitchiner's book:
The use of quotes around a forty winks nap seems to indicate Kitchiner might have borrowed the phrase from elsewhere, but I can't find it in any form earlier than his use of it. Also, Kitchiner carefully footnotes other phrases and passages from different authors throughout his book.
There was also the idiomatic expression nine winks in the mid 19th century. Eric Partridge in his The Routledge Dictionary of Historical Slang claims that the term already existed in 1820. I found evidence to support this in John Badcock's: Slang: A Dictionary of the Turf, the Ring, the Chase, the Pit, of Bon-ton printed in 1823. The slang term "forty winks" was not yet listed, which suggests that the idiom was either too new to have merited its own entry or had not yet been coined.
As the earliest recorded evidence of forty winks is found in 1822, it is most likely that John Badcock was unaware of its existence. In light of this, Kitchiner was probably referring to the established nine winks phrase when he placed his (neologistic) "A Forty Winks Nap" in quotes.
Online Etymology Online reports only that its usage was attested from 1828.
The expression had been used by Lewis Carroll in his novel Sylvie and Bruno, and F. Scott Fitzgerald used it in a short article titled Gretchen’s Forty Winks.