The Egyptians had a tradition to place special papers with spells into the dead person’s grave. Those charms were the books of the dead. The Egyptians believed that after death the person’s soul went to a special world where it had to overcome some obstacles and become immortal. And those books of the dead were made to help the dead ones.
This tradition began in the New Kingdom (about 1550 B.C.)