Ghosts represented as sheets come from the tradition of burial shrouds.
For thousands of years, unless you were wealthy, you weren’t buried in a coffin. Most people were buried in other ways and one of the most common was in a shroud or sheet of some kind (the original green burial). Coffins didn’t become common in Europe until the 18th century. So until then there were a variety of different kinds of shrouds but the basic idea was that the deceased was wrapped in cloth and lowered into their grave.
In this context, the idea of seeing a sheet/burial shroud walking about in the dark is terrifying. This is the origin of ghosts being portrayed as sheets – it’s from the understanding that a deceased person in their burial shroud was out of the grave and back from the dead. In 19th century Britain impersonating a ghost in this fashion became both a prank fad and a real problem. At best a prankster would wear a sheet, run around at night, and generally frighten people in humorous ways. At worst it was a way to terrorize and assault women. There are even a few incidents of these “ghosts” frightening people out of their homes, leaving the house temporarily free to be burglarized (the original Scooby-Doo villains). It was also used in mid 19th century America by the Ku Klux Klan who pretended to be the ghosts of Confederate soldiers, come back to terrorize the people of the south.
This motif of ghosts being represented as moving burial shrouds/sheets found its way into entertainment by way of the theater in the late 19th century. The ghosts of the stage would be in white sheets, move silently, and generally do the spooky things we think of today. Early animated cartoons portrayed ghosts in a similar manner, most notably with Casper the Friendly Ghost (who is shroud-like). Today the motif is fairly harmless and pretty ubiquitous. You see it in the iconic Ghostbusters logo, the ghosts in Pac-Man, Boo from the Mario games, the ghost mascot of Snapchat (aka “Ghostface Chillah”), Boo Berry cereal, the ghosts of LEGOs, Halloween Tootsie Pop ghosts, etc. The burial shroud ghost continues to live on.