In Shakespeare's time, mattresses were secured on bed frames by ropes. When you pulled on the ropes the mattress tightened, making the bed firmer to sleep on. Hence the phrase......... "goodnight, sleep tight."