Erlang Shen, whose real name is Yang Jian, is the son of Xianfan, an immortal in ancient myths, with high magical power, comparable to Sun Wukong in the description of Journey to the West, and in the depiction of Feuding the Gods and Journey to the West, his mother is still the Jade Emperor's sister, and he is the son of his mother, Sifan, who stole down to the earth and married with a mortal. As for why he has a third eye, it is said that it was during the Qing Dynasty that this saying emerged, and before that, it was not stated that Yang Jian had a third eye.
Legend has it that Yang Jian's third eye has the function of making demons and monsters visible, similar to Sun Wukong's fiery eyes. As for why Yang Jian has a third eye, there are many speculations.
The first theory is that he transformed his eyes with magic treasures. Because his mother was a fairy, he inherited his mother's magical power, did not know how to control it, and would harm the people if he was a little bit careless. Seeing this, he was taken as a disciple by the Jade Tripod Truthful, and taught him to control his magical power, and, at the same time, gave him the magical treasure, which was transformed into his third eye, so that he could recognize demons and devils, and help him to subdue the demons and get rid of the devils.
The second theory is the one in the Prequel to the Po Lin Lamp, which says that the third eye is a heavenly eye accessory, owned by Yao Ji, Yang Jian's mother, which can see through all the illusions, and Yao Ji later violated the heavenly rules by marrying Yang Tianyou privately and giving birth to three children, including Yang Jian, who was discovered by the Heavenly Court, and gave Yang Jian the heavenly eye accessory before her family was broken. Yang Jian, on the other hand, learned the correct way to use the Eye of Heaven on his way to save his mother and learn magic power. From then on, the Eye of Heaven became one of his magic treasures, which transformed into a third eye to help him when he needed to use it, and when he didn't need to use it, it was used by him as an accessory to wear around his neck.