This episode is based around a therapy session House has with Dr. Nolan. It's been a tough week for House because Wilson asked him to move out in order for Sam to move in.
Also, House recounts a case he dealt with that focused on a woman with amnesia. Her husband objected to a procedure that would have saved her life, yet robbed her of her long-term memories. House says this irritated him because people act irrational when love is involved - but Nolan realizes that House is bothered by this couple's relationship. In what way? He can relate.
First, House feels like he's losing Wilson, who has chosen Sam over his best friend. After learning that Cuddy is moving in with Lucas, he fears he is losing her, as well. Part of House's story to Nolan involved tracking down a rare medical book that Alvie (more on him soon) had pawned. Why did House want it so badly? Because Cuddy's great-grandfather wrote it and House wanted to give it a gift. He's had it for years.
So, yes, Alvie randomly showed up. He'd been staying in House's apartment while House was living with Wilson and has pawned some of House's things in order to afford expensive paint for the place. Very random, but we do love Lin-Manuel Miranda in this role. He ended up sticking around and helping House with a case.
But after House helped Alvie with his immigration case, he became the latest to leave House, going off to Phoenix to live with his brother. This all made House realize that he's not happy, as Nolan had promised he would be. He's simply alone.
As a result, the episode ended with House walking out on the doctor, saying he isn't the answer.