The world is divided between those who believe in ghosts and those who don't. Personally, I do believe in the entities which reside in the "other world," but there has yet to be definitive proof where I can definitively say ghosts are real. However, without claiming to a demonologist, expert or scientist, I can throw out a hypothesis about ghosts.
First, to understand this hypothesis a question needs to be posed: Have you ever been through sleep paralysis? If you have, then you should be familiar with the eerie feeling of someone or something watching you or near you. You would also be familiar with the feeling of unable to breathe, move or speak. The one noticeable thing that people who have gone through sleep paralysis always speak about is some weird figure being close to them. "Some scientists have proposed sleep paralysis as an explanation for reports of paranormal phenomena such as ghosts, alien visits, demons or demonic possession, alien abduction experiences, the night hag, and shadow people haunting."
Perhaps it is the current state of mind, under sleep paralysis, when the brain is in a fluctuating sleeping and waking state. Maybe when people are conscious their logical minds are programmed to not believe or see ghosts and demons. And obviously, when people are in a sleeping state, you have no visual perception. Therefore, when the brain is fluctuating between an unconscious and conscious state, the brain "malfunctions" in a way where an apparition is visible by the person under sleep paralysis. Although sleep paralysis is not common (or shouldn't be anyway) I believe it is a gateway to remind humans that otherworldly beings do have a place on Earth.
If you're not convinced on the hypothesis of sleep paralysis, then what about when little children claim they see ghosts? There have been numerous stories, claims, and accounts about seeing monsters or ghosts. Could it be that because their brains haven't fully developed that they can think and see creatively? Do we gain the potential to tap into our children's mind under sleep paralysis? Since the paralysis literally means the inability to function or act, and children develop and grow mainly when they sleep, sleep paralysis would indicate the temporary halt of development. Therefore, if the development we had undergone as a child due to sleeping was halted or paused, then would it be too farfetched to claim that we were given our child's developmental stage temporarily?
All these are thoughts and speculations because until ghosts are proven to exist, there will be literally nothing backing their existence.