Not to discourage further answers, but u/thejukeboxhero answered that in How did ghosts become associated with white sheets? and here.