Ra in the ancient Egyptian mythology was the sun god and the father of all the other gods and goddesses who grow older and weaker in his declining years and began to commission his faithful, wise and powerful assistants with some of his daily chores in order to lessen his burdens. In spite of that he kept his secret name as a secret that none of the immortal and the mortal creatures know. Knowing that secret name was the golden means that enable its owner of controlling over the whole world and even controlling over Ra himself. That’s why Ra exerted a lot of effort in order to protect that name and keep it as a secret until Isis made her vicious successful plan and took it. Isis, the wife of Osiris and the mother of the Younger Horus, was known for having a great magical power. She plotted against her grandfather and the Chief god in order to gain more power and control over the whole universe.
She used her magical power by taking some of the ground mixed with Ra's spittle that was falling from his mouse when he grew older and turned them to a cobra that can kill any of the gods or humans even Ra himself. She put that snake in the way of Ra's solar boat and this snake managed to pit him. Ra suffered severely from the poison of that snake especially because he was at an old age. None of the surrounding gods was able to help him and at that time she began to practice pressure upon him to tell her his secret name and give his eyes to her son Horus and she would save him from death in exchange. At the beginning, Ra told her a false name and when she knew that she told him that she is the only one who can save him from his suffer and after a long bargain he told her his name and she made the poison gets out from his mouth. She used the power of the name in increasing the power of her son Horus and the eye of Ra became the eye of Horus and Ra was forced to retire.
This myth was mentioned in two papyri one of them is the papyri of Turin that date from the 12th dynasty. It justifies the reason for which most of the ancient Egyptian kings had had more than one name and one of them was associated with the name of god and was written on the walls of his temple and his religious monuments. This myth was presented in the ancient ages in order to demonstrate the great influence of the curse against the serpents and also to tell the people about the spell that they can use to overcome the poison of the snake.
You can get more information here.