Stark Raving Dad is the first episode of Season 3.
Thanks to Bart leaving his lucky red hat in the load of washed white shirts, Homer wears a pink shirt to the nuclear power plant. He is promptly committed to a mental institution where he meets up with a heavy-set, bald, yellow man, Leon Kompowsky, who walks and talks like Michael Jackson. The other theme of the episode is that Bart doesn't know what to get for Lisa's birthday.
Lisa reminds Bart that her birthday is coming up and not to forget to get her a present. Homer's traditional white shirt turns pink in the wash (thanks to Bart red cap being mixed in with the shirts), and he is forced to face the ridicule of his co-workers by wearing pink to work. He catches the attention of Mr. Burns, who pegs him as "some kind of free-thinking anarchist", and orders him to be examined by Dr. Marvin Monroe. After receiving a take-home psychological test from him, he has Bart fill it out for him. After handing it in, he is promptly judged to be insane and committed to a mental institution. There he is bunked with a large yellow man who claims he is Michael Jackson. The two quickly become friends.
The day of Lisa's birthday, "Michael" calls the Simpson household to let Bart know that Homer has been committed, and Marge starts working on a way to get him out. Marge manages to convince the institution that Homer is not really crazy by pointing out Bart's antics that made Homer go crazy in the first place. Homer invites "Michael" to their home for the night. Bart, believing that Leon is really Michael Jackson, begins to inform all his friends that he is on his way. Meanwhile, in all the commotion, Lisa seems to be forgotten.
The word that Michael Jackson is on his way to Springfield, begins to spread through the town, and a large crowd forms around the Simpson house. When the two of them arrive, and the crowd sees a large, white man instead of Michael Jackson, the crowd gets angry and disperses. After the melee, Bart admits to Lisa that he forgot to buy her a birthday present. Lisa storms off, crushed.
That evening, Lisa writes a letter to Bart saying that she is disowning him. "Michael" hears everything and then approaches Bart and tries to convince him to write Lisa a song to make up to her. After Bart confronts him about his obvious delusion about being a famous recording star, they get down to writing, and eventually compose a ballad called, "Happy Birthday Lisa." The next day Maggie wakes up first to have breakfast and do her work, Upstairs, they perform it for her, and all is well again. After this, "Michael" tells them all that his real name is Leon Kompowsky, and he's a bricklayer from Paterson, NJ. He tells them that he was an angry and unhappy man until he started talking like Michael Jackson and saw that it made everyone around him happy, which in turn made him happy, so he just kept on doing it. Leon then takes his leave, walking down the street singing Lisa's birthday song in his normal voice.
Michael Jackson himself voiced Leon Kompowsky's dialogue, and sound-a-like Kipp Lennon performed all the singing parts. Jackson's guest appearance was credited to "John Jay Smith." The DVD commentary for this episode indicates that Jackson approached the Simpsons team wanting to appear on the show. In the first weeks, Michael Jackson intended to be voiced Leon Kompowsky's dialogue and singing parts while Kipp Lennon intended to write the song just like Mozart did, but due to a contract obligation, Jackson was not allowed to sing and Kipp Lennon gave it to Jackson as a writer and Kipp Lennon voiced all singing parts just like Jackson instead. However, he did write "Happy Birthday, Lisa" for the show. Great secrecy surrounded the guest appearance for some time, and even Matt Groening, when appearing on the Jay Leno show, did not openly reveal that it was Jackson (although he hinted strongly). It wasn't until the episode "Itchy & Scratchy: The Movie" that a more open clue was given to viewers, when Lisa mentions that Dustin Hoffman and Michael Jackson made cameo appearances in the movie, stating, "They didn't use their real names, but you could tell it was them..." (Dustin Hoffman, of course, voiced Mr. Bergstrom in the episode Lisa's Substitute, and his guest appearance was similarly shrouded).