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."