In ancient egypt, important men, especially kings were buried in large coffins after their death. Mythical monuments were built around their tombs and promising rituals prepared their souls for a journey to the afterlife, where the god of death was the guard of the gates of a utopian sanctuary.
The egyptians believed in the immortality of the soul. They believed that the journey of the souls would take them to a heavenly realm called the Field of Reeds. There the souls would reach a place free of sickness, disappointment and death. According to the ancient paintings, the Field of Reeds was a haven of agriculture. It was a peaceful utopia reserved only for the good and the pure hearts.
Before entering the afterlife, souls travelled through their tomb to reach it. Each and every soul gathered in the Hall of Truth for the judgement of the Lord of the Underworld. This god of death placed the soul's goodness on a golden scale and weighed it against a white feather of truth. If the souls heart was heavier, it fell to the floor, where it was devoured by a god with a crocodile's head. If its heart was consumed by the crocodile god the soul was erased from existence. And if the heart was lighter than the feather, the god of death along with his council would discuss your fate. And if they believed the soul to be honest and good, he would welcome the pure of heart into the Field of Reeds.
As by this job, the god of death played a critical role in the immortality of ancient egyptian souls.
At the early times, jackals were a troublesome animals who would tear up and eat the corpse of the dead and so it was believed that the soul wouldn't travel to the afterlife without the body being intact. So the egyptians made offerings to the Jackal headed god of death called Anubis. And for hundreds of years Anubis served as the protector and the gaurdians of souls. The discovery of mummification happened around his time, to protect their corpses from damage and decay.
A very famous myth says there was god pharoah named osiris. He was tricked into an affair with goddess Nephthys, also the wife of the god of war and chaos, Seth. The affair bore a child and when seth discovered about this, he split Osirs's body into pieces, locked them into boxes and threw him into the River Nile. Osiris's remains were recovered by his wife, Isis. She brought these to Anubis and he bought Osiris back to life. And after some time Osiris became the god of the underworld and Anubis was dethroned. So now what he did was to guide and protect the souls and became the right hand of Osiris. Once the god of death, now the conductor of souls. Anubis was a leader and a caretaker.