Warning: SPOILERS ahead for Legion
After much speculation, we now definitively know the identity of Legion's “devil with the yellow eyes.” Taking a variety of appearances - including an adorable beagle puppy, a storybook character, a bulbous monstrosity and Aubrey Plaza - the Shadow King is a mysterious possessing force that has fed off of David Haller's (Dan Stevens) psychic powers since he was a baby. But who is the Shadow King, exactly?
Within the context of the FX series, the Shadow King appears to be a very powerful mutant who also goes by the name Amahl Farouk, and has an adversarial history with David's father. The precise identity of Legion's father is a point of debate, but based on the fact that he apparently has telepathic abilities, is bald, wears a suit, and uses a wheelchair (as glimpsed in a brief flashback), we can safely assume that he's probably Professor Xavier (as he is in the X-Men comics).
At some point in the past, David's father and Farouk fought on the astral plane. David's father won, but Farouk didn't die. Instead, his mind lived on in the astral plane. Thirsty for revenge against his rival, Farouk possessed the infant David, siphoning his powers (and exacerbating their hallucinatory symptoms) with the intention of eventually becoming strong enough to kill David's father or possibly even take control of the world.
Farouk was very careful to keep David ignorant of his presence, overwriting any memories related to him with images of a beloved pet dog (King), a trusted friend (Benny/Lenny), or a frightening childhood fantasy (The World's Angriest Boy in the World). Farouk's poisonous influence eventually led David to attempt suicide, which in turn led him to Clockworks, Syd and Summerland. The Shadow King realized that it couldn't remain in hiding any longer, and started to intervene more directly in David's life, seizing control of his personality and later trapping him and his allies in a psychic construct modeled after the Clockworks psychiatric hospital.
This is somewhat similar to how the Shadow King is portrayed in the X-Men comics, though some of the details are a little different. In the comics, Amahl Farouk is indeed Professor Xavier's rival. In fact, he's the very first evil mutant that Xavier encounters - an obese crime lord with immense telepathic abilities. They meet in Egypt and engage in a psychic battle. Xavier emerges the victor, while Farouk's physical body dies and his mind escapes into the astral plane. This is a pivotal moment for Xavier that eventually leads him to create the X-Men, while Farouk lives on as a (seemingly unkillable) incorporeal being.
Farouk is eventually referred to as the “Shadow King” and proceeds to torment the X-Men many times over the years, mostly by possessing telepaths (such as Karma and Psylocke) and bending others to his will. The TV character's swollen, corpulent appearance isn't a completely original invention either; when the Shadow King possesses Karma, she takes on a more obese physical form.
The Farouk of the comics isn't quite so specifically focused on David Haller and his abilities. Unlike the show's version of Farouk, he didn't possess David as an infant and remain inside him for most of his life. David was, however, Farouk's host of choice during a portion of the “Muir Island Saga,” where he tried to amass an army of thralls and take control of the physical world. Xavier managed to reach Farouk on the astral plane and defeat him once again, but the fight left Legion in a catatonic state.
The TV show seems to treat "Amahl Farouk" and "the Shadow King" as the same entity. In the comics, it's eventually revealed that the man known as Amahl Farouk was never actually the Shadow King at all, but rather, just another of its hosts. Though its exact nature is left somewhat vague, the Shadow King isn't really a “mutant” as we understand it; it's a psychic entity that has been around since the existence of nightmares, born out of the dark side of the collective human consciousness. This is one of the biggest divergences from the TV show, though it's entirely possible that the FX series has yet to go more in-depth with Farouk's backstory and the Shadow King's true nature will eventually come to light.
In a sense, that nature is very fitting for a TV show with mental illness as one of its major themes. The Shadow King isn't simply a mutant who tricks David into thinking he's crazy; it's an manifestation of mental illness itself. And much like many forms of mental illness, the canonical Shadow King can never truly be killed—it can only be managed.
We'll most likely find out the ultimate fate of both David and the Shadow King during the season finale of Legion, which airs tonight at 10PM on FX.