Those who are very sinful & attached to their family, house, village or country do not receive a gross body made of material elements but remain in a subtle body, composed of mind, ego, intelligence. Those who live in such subtle bodies are called ghosts
SB Canto 4
The fortunate inhabitants of Pitṛloka, who preside over the funeral ceremonies, made Aryamā into a calf. With great faith they milked kavya, food offered to the ancestors, into an unbaked earthen pot.
In Bhagavad-gītā (9.25) it is said, pitṟn yānti pitṛ-vratāḥ. Those who are interested in family welfare are called pitṛ-vratāḥ. There is a planet called Pitṛloka, and the predominating deity of that planet is called Aryamā. He is somewhat of a demigod, and by satisfying him one can help ghostly family members develop a gross body. Those who are very sinful and attached to their family, house, village or country do not receive a gross body made of material elements but remain in a subtle body, composed of mind, ego and intelligence. Those who live in such subtle bodies are called ghosts. This ghostly position is very painful because a ghost has intelligence, mind and ego and wants to enjoy material life, but because he doesn't have a gross material body, he can only create disturbances for want of material satisfaction. It is the duty of family members, especially the son, to offer oblations to the demigod Aryamā or to Lord Viṣṇu. From time immemorial in India the son of a dead man goes to Gayā and, at a Viṣṇu temple there, offers oblations for the benefit of his ghostly father. It is not that everyone's father becomes a ghost, but the oblations of piṇḍa are offered to the lotus feet of Lord Viṣṇu so that if a family member happens to become a ghost, he will be favored with a gross body. However, if one is habituated to taking the prasāda of Lord Viṣṇu, there is no chance of his becoming a ghost or anything lower than a human being. In Vedic civilization there is a performance called śrāddha by which food is offered with faith and devotion. If one offers oblations with faith and devotion—either to the lotus feet of Lord Viṣṇu or to His representative in Pitṛloka, Aryamā—one's forefathers will attain material bodies to enjoy whatever material enjoyment is due them. In other words, they do not have to become ghosts.