Anubis is an ancient god, his existence most likely pre-dates the building of cities along the Nile.
His origin is probably found in the habit of jackals or other canids of digging up human burials in graveyards on the outskirts of settlements.
He became known as the god who escorted the dead to judgment.
Anubis often appears in wall paintings as a witness as the heart of a dead person is weighed against a feather on the scales on Ma’at.
Later the god Osiris joins, and sometimes replaces, Anubis as guide of the dead.
The advent of the god Osiris, who is associated with the embalming of corpses, probably represents the initiation of the custom of preserving the bodies of the elite as mummies.
Osiris is held to have been destroyed by his brother Set, who dismembered his body and scattered the parts through Egypt.
Their sister Isis gathered together the parts of Osiris’ body, all except the penis, which had been swallowed by a fish, and restored (ie embalmed) him.
Anubis invented embalming in order to preserve the body of Osiris.