Lamia was a demigod and a daughter of Hecate.
Lamia was the queen of Libya and attracted the attention of Zeus and accepted his courtship. But upon doing so, faced the wrath of the jealous Hera. Hera killed two of her children, Altheia and Demetrius (Herophile and Acheilus could not be harmed), and then Lamia was turned into a monster. Angered at the goddess, she used an incantation to allow all the monsters in the world to sense the taint of half-bloods, so that they could always be found. Lamia did it out of spite so that Hera would finally understand her pain of losing her children after so many demigods have been killed.
In later stories, Lamia was cursed with the inability to close her eyes so that she would always obsess over the image of her dead children. Some accounts say Hera forced Lamia to devour her own children. Myths variously describe Lamia's monstrous (occasionally serpentine) appearance as a result of either Hera's wrath, the pain of grief, the madness that drove her to murder, or—in some rare versions—a natural result of being's daughter.
Zeus then gave her the ability to remove her eyes. The purpose of this ability is unclear in Diodorus, but other versions state Lamia's ability to remove her eyes came with the gift of prophecy. Zeus did this to appease Lamia in her grief over the loss of her children and to let her rest since she could not close her eyes.