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:
It means a short nap durning the day but not in bed. I read it was first used in the early 1800's.
Why the number I don't know.
It is believed the 40 was used as a tradition going back to biblical times of using 40 for an undetermined amount of time. Examples would be the flood that lasted 40 days and 40 nights, or the number of years the Israelites wandered.
Here is where I found that. www.wordwizard.com/phpbb3/viewtopic.php?p=33068