The traditional conception is that ghosts aren’t really sentient creatures, but a phenomenon that souls can get stuck in instead of going to the afterlife. There’s symbolism there - a ghost is an echo of a person, much like memories of them or the effects they had on the world. There’s also a bit of Christian moralizing - a “good” person doesn’t stick around because they are eager to join God in heaven, while a “bad” person clings to their earthly life and possessions even if they are only capably of doing so in a greatly diminished state.
The modern conception of a ghost where it’s a fully realized person who can just kinda go through walls is an anthropomorphized and secular version of the ghosts that were invented by the Victorians.
They call that the Peter Principle, and there’s at least one Ig Nobel Prize winning study which found that it’s better to randomly promote people rather than promote based on job performance.