Ghost Pokemon are probably uncommon, not all Pokemon/Humans that die become Ghost Pokemon, and not all Ghost Pokemon are the ghosts of deceased Pokemon/Humans.
There is also a Spirit World (
http://bulbapedia.bulbagarden.net/wiki/Ghost_World ) that appears in the Anime (where a Lampent and some Litwicks attempt to drag Ash & crew in one episode) and mentioned in Pokedex entries, so its likely that Ghost Pokemon can move on from the world at some point and pass into an afterlife of sorts.
A bunch of the Ghost Pokemon are designed after the Japanese folklore of various evil spirits and objects. To properly understand the basis of Ghost Pokemon you would need to look into the Japanese view on spirits and ghosts.
One such example is their view on objects being able to become ghosts: "For tools used in human life, there was the way of thought that, as months and years pass by and these tools become older, they have an ability to become apparitions."