For centuries scientists believed the hieroglyphs and passages found written and carved onto the faces inside and outside of Egyptian tombs and pyramids were an ancient language or scripture. However in 1842 a German Egyptologist, named Karl Richard Lepsius, published a collection of ancient Egyptian mortuary texts known as 'The Chapters of Going Forth by Day' which discredited these theories going forth known commonly as the Book of the Dead.
When scholars learned to decipher the hieroglyphs it became known that the writings on the tombs were in fact a road map for the souls of the dead to find their way through the afterlife safely. These hieroglyphs which are now known to be magic spells have been found on buildings, walls, bandages and offerings. It was very important to the ancient Egyptians to prepare the bodies after death for a safe journey and this included leaving them these maps towards the afterlife.
Lepsius' structuring of these spells into a chaptered book (200!) helped organise the thousands of heiroglyphs and writings making it easier for scientists and scholars even today to study. Although funnily enough the book is still very scattered and no two copies are ever the same.
Image source: National Geographic
These spells for the afterlife are known to have begun as far back as 2600 BC on the pyramids, in this time period they were reserved only for royalty. As the years progressed anyone rich enough was able to acquire and use the passages. As time went on even further the writings became more widespread and were sold to offer safe journey through the afterlife for anyone.
The writings depict the preparation of the body and soul for the afterlife. Then act as a guide on how to go about passing the tests and trials through the journey to spiritual and physical idyll. These guides or passages are often left on the deceased's tomb and among amulets placed with the body after death. The spells did not guarantee safe passage however would offer assistance and passwords to pass certain stages of trial. The Egyptians believed that if a person was properly prepared for the afterlife then their soul was immortal.