The story
Outgrowth of the earlier idiom, to hit the sack, with possible influences from other senses of to sack (“tackle, pillage”, verb), and to sock (“hit, slam”, verb), providing an implication that sleep has been thrust upon a person.
Etymology from Wiktionary, CC BY-SA 4.0.