Ghosts aren't real, but the folklore around them has to conform to acceptable societal norms, particularly in the context of Victorian era Britain where the cultural template for most Western ghost stories originates, so ghosts have to be depicted with the necessary modesty unless offending that modesty is an intentional theme.
Also, clothes are useful for signaling a "ghost's" identity and status.
Are ghost clothes made from ghost cotton? Or is there a mystical alteration process to convert human clothes to those that ghosts can wear?
Jokes aside, I am wondering if cynicism and humorous over-analysis is a recent phenomena, because the general population is more educated/have basic needs met than those in Victorian times.
An important principle in folklorists study of legends (which many ghost stories fall under) is that the legend cannot be separated from its telling. That means that telling legends is generally a group process. For example, after someone tells a legend someone else might speak up to add some details that they heard; only to be interrupted by someone to contest a point, and so on. I suspect that in that framework there have always been people who play the role of the skeptic who provides alternative interpretations or the practical joker who makes light of the story.
This is what happens when people still have a desire to believe in a metaphysical reality, but want to reconcile that with their understanding of physical reality. It's assumed that ghosts are real actual disembodied spirits of the dead because belief in them serves a cultural need, but in a modern society not entirely governed by magical thinking, such beliefs don't seem practical enough to be comforting. The attempt to move past "superstition" and ground the supernatural in science was the driving impetus behind the spiritualism movement (that and grift.)
You see the same incentives in the modern day with Biblical literalism and flat earth, and UFO folklore where "ultraterrestrial" and "interdimensional" theory shows up. It seems like science if everything you know about science comes from Reddit and TikTok but it's really just three space goblins stacked in a lab coat. Three because, of course, three is a sacred number.
There's no explanation for why ghosts wear clothes that isn't less ridiculous than the obvious, that it's because we imagine people wearing clothes, and ghosts are imaginary people.
“Real” in the sense it exists within your mind, which exists (somehow) within your brain, which is itself likely real. So your imagination must have some physical basis, but it would exist entirely within your brain (or body, to the extent the rest of your body influences the brain itself).
Your brain imagining a specter in a doorway does not mean there is any anomaly within the physical space of the doorway at all that anyone else could perceive or measure - they would need to measure your brain to (theoretically) detect the physical basis of it.
What you see, feel, hear, taste is an interpretation of your physical environment, and may not accurately reflect it at all times.
It’s interesting, because there are textbooks that say the magnetic field lines aren’t real, but are a good visual of what happens when a magnetic particle is there…
I know funny isn't really the goal for comments around here but man that made me laugh. So subtle and obvious at the same time and quite an appropriate response to the posed question!
To tack on to the amount of complexity; your brain’s operation allows you to perceive a world outside your brain, but the actual perceiving of it happens inside your brain, which again rests inside the perceived world more or less..
Also, clothes are useful for signaling a "ghost's" identity and status.