Покойник retains qualities of a personality which a труп does not.
We can speak about name, age, property, character, relatives, friends, colleagues, occupation, nationality of a покойник.
We cannot speak about say, relatives or name of a труп. Труп is a body, corpse, покойник is a person.
Consider
Покойник был старый
Means the deceased was old when he died.
Труп был старый
Means the corpse was lying here for a long time since the death.
Покойник can be молодой, but a труп only can be свежий.
Similar distinction exists not only among the dead but also among the alive: compare "человек" and "тело человека". While both may refer to the same physical object, the "тело" is inanimate. We can speak about water and fat reserves of a "тело человека" but we can talk about water and fat reserves of a человек only in the sense of property.