It's an Americanism from the early 20th century. Primitive mattresses consisted of a sack stuffed with hay, so we got 'hit the sack' as well, meaning the same thing...go to bed. The 'hit' element just means there is to be contact between sleeper and bed, just as there is between a walker's feet and the ground when he decides to 'hit the road'.