The earliest match for "sleep like a top" (or its variants) that I could find in a Google Books search is from Francis Beaumont & John Fletcher, The Coxcomb (circa 1608–1610):
Valerio. When they [the Watch of the city] take a Thief, I'll take Ostend again; the Whoresons drink Opium in their Ale, and then they sleep like Tops: as for their Bills, they only serve to reach down Bacon to make Rashers on; now let me know whom I have done this Courtesie to, that I may thank my early rising for it?
In a note attached to this passage from Shakespeare's Twelfth Night (circa 1601–1602)—
Sir Toby. With drinking healths to my Neece: Ile drinke to her as long as there is a passage in my throat, & drinke in Illyria: he's a Coward and a Coystrill that will not drinke to my Neece. till his braines turn o'th toe, like a parish top.
—Samuel Johnson & George Steevens, Supplement to the Editions of Shakspeare's Plays (1778) syas this:
To sleep like a town-top," is a proverbial expression. A top is said to sleep, when it turns round with great velocity, and makes a smooth humming noise.
Robert Nares, A Glossary; or, Collection of Words, Phraes, Names, and Allusions to Customs, Proverbs, &c. Which Have Been Thought to Require Illustration, in the Works of English Authors, Particularly Shakespeare, and His Contmporaries (1822) includes this further note by Steevens regarding "the parish top" (which Nares defines as "A top bought for public exercise in a parish"):
A large top was formerly kept in every village, to be whipped in frosty weather, that the peasants may be kept warm by exercise, and out of mischief, while they could not work.
Yet another set of notes to Twelfth Night, this one from 1857, cites further early instances of sleeping like the town-top:
"Thinking it had power to keep, town-top like, itselfe asleepe," verses pref. to Strong's Joanereidos, 1645. "The people will not, like a town-top, fall asleep with scourging," Rebellion of Naples, 1649, p. 10.
William Hazlitt, English Proverbs and Proverbial Phrases Collected from the Most Authentic Sources (1882/1906) has this relevant entry:
To sleep like a town-top. An allusion to the top, which was formerly purchased in towns and parishes for public use, and from its size, when spun, was apt to sleep unusually long.
These early references and glosses suggest several things that may have helped make "sleep like a top" proverbial. First, a properly whipped top's tendency to stay spinning in place for an extended period of time, while making a smooth humming sound, was termed sleep. Second, the unusually large size of town tops increased their tendency to spin in place (that is, sleep) for a long time. And third, the fact that town tops could sleep despite being repeatedly whipped (traditionally, with thongs made of dried eel skin) may have suggested a remarkable ability to sleep soundly.