I think that energy has to go somewhere when we die.
And I believe that, with sudden deaths, the energy is expelled and can continue functioning as a separate being.
I also don't believe just because there is a ghost is will be evil; it has to be a bad person to be a bad spirit.
I also think that's why you only see ghosts in the dark; they are pure energy, and the purest form of energy is light. During the day there is too much light to see the spirit, but during the night the spirit is brighter than it's surroundings.