Ghosts have their reasons, and well, it's complicated. There is no one-size-fits-all explanation. It depends on the character of the spirit, how they died, their age, and their beliefs. But I'll try to break it down based on what I've learned so far.
They don't know they've passed
Young children often don't have a good understanding of death so when they pass, they may remain believing they are still alive. It takes spiritual intervention, ideally by a trained psychic medium, to convince them to go to the other side. Other spirits may have been victims of sudden, traumatic deaths. And they don't know they're dead so they continue with whatever they were doing at the time. They too can be helped with spiritual intervention.
They fear the Other Side
Some spirits fear their final judgement. Perhaps they were bad people in life, or they had a strict religious upbringing that literally put the Fear of God in them, so they worry crossing over means a one-way ticket to hell. I was once part of an investigation in very old home outside of Vancouver that had been turned into a museum. The boys' room had several religious icons in one corner because the local priest would often stay the night in that particular room. We picked up the presence of the priest who remained more than 100 years after his death. What our communications with him told us was that he was afraid of his judgement.
They are still suffering
In life, some spirits have experienced great sadness, confusion, trauma or injustice. Death is not an immediate fix. So many stay in an unresolved state of suffering. The Lady in White of Gastown is an example of this situation. She weeps pitifully at the window, unable or unwilling to let go of her pain. For others, it may be a case of unfinished business (cliché but it happens), such as their unsolved murder or disappearance. However, not all Cold Case File victims are lingering. It just depends on the person/spirit.
They watch over us
Spirits still care about their loved ones. Many will stick around until they are satisfied their friends/family are carrying on well enough without them. And sometimes they stay to watch over other spirits. I met a paranormal investigator/medium who told me of an investigation she attended at an old orphanage. The spirits of several children remained, as well as a woman who was their caretaker. Once they managed to get all of the children into the light (no easy task), the woman willingly moved on too. Turns out, she cared so much for these children she couldn't leave them while they were stuck on this earthly plane.
They're at home
Sometimes the attachment is to a place they loved. I've heard several stories of people moving into homes and finding the ghost of the former owner still around. With these former owners, it's often the case that they spent many years in the house and felt a great deal of pride in their home. And usually once the old owner feels that the new owners are worthy enough to live in their home, they will move on. Or if they don't approve, they will make life unhappy for the new owners until they move out.
But other times, they just don't move on. It's not uncommon to find ghosts from the 19th century hanging out in Gastown. They seem peaceful, intelligent and willing to communicate. When we ask them why they stay here instead of moving on they simply answer, This is my home. But they also tell us that Gastown is full of bad spirits, more bad than good. Do they stay to balance out the good and the bad? Are they looking out for us? It's a mystery to me.
They're just visiting
Spirits can cross over and then come back to visit. So don't worry if a family member appears to you after being departed for years. They just want you to know they still care and watch over you, but mainly from a distance and occasionally in person when you really need to see them.
They're not really here
There's a big difference between active hauntings, which involve a sentient spirit, and residual hauntings. Sometimes what we experience are loops of energy trapped in a location, replaying a specific scene. Like long-ago passengers waiting for a train in Waterfront Station, people running from the Great Fire in Gastown, or the usher standing at the coat check in the Orpheum.