I believe its a term used when there were cockroaches etc. You had to tuck the bedclothes in so that they couldn't crawl up them from the floor (there were bowls of water around the legs of the bed so they couldn't get up that way)
It dates back to the days when beds were constructed from criss-crossed roped slung between the sides of the bed frame. over time, the ropes would slacken with the weight of the sleeper giving a bowed matress support, and a bad night.
If you 'slept tight', you were on a bed that had just had its ropes tightened, so you were assured of a good night's sleep.
Click here for the opinion of Michael Quinion, a noted etymologist and lexicographer...ie word/phrase expert. He suggests that Andy's idea above is a possible origin but suspects that the phrase is much too recent for that to be the case. Given the dates quoted, so do I.
In Shakespears time mattresses were secured on bed frames by ropes. When you pulled the ropes the mattress tightened. Hence the phrase....good night sleep tight.