This seems to me to be the sort of thing we probably inherited from Christianity, though I have no proof.

Because of Christians belief in physical resurrection, they have always been very concerned with what happens with the body after death. This gave Christianity very complex death rituals and various taboos and beliefs about grave sites. And naturally with such beliefs, Necrophilia would be a terrible offense.

Jay