The phrase "sleep tight" originated when mattresses were set upon ropes woven through the bed frame.(before box-springs were invented) To remedy a sagging, uncomfortable matress caused by sagging and loose ropes, one would use a bed key to tighten the rope.
Means have a good sleep