When a person dies only his gross body ceases to exist. His subtle-body however continues to exist and moves on to the other regions of the universe. Refer to the picture below for more detailed view of what we are comprised of and what we leave behind after death.
Only people who have reached the 50% or 60% spiritual level and have low ego are able to proceed to the higher regions of Heaven and beyond and do not become ghosts. The rest of humanity, when they die, finds themselves in the regions of the Nether world and Hell. Most subtle-bodies in the Nether region are highly likely to become ghosts. All subtle-bodies in Hell are ghosts.
In fact, even if one is a gentleman but doesn't have enough spiritual strength through spiritual practice, he is liable to become a ghost when he dies. This is because he is attacked by higher level ghosts and is controlled by them.
Ghosts of a higher level, with their high spiritual strength, make the subtle-bodies of 'gentlemen' of lower spiritual strength, do things against their will and thus indirectly make them ghosts.
The moral here is that, if we do not undertake spiritual practice according to the universal six basic principles of Spirituality and do not reduce our ego, then the probability of us becoming ghosts, after our death is very high.