Why did Barney Stinson (Neil Patrick Harris) have a fake family on How I Met Your Mother? Barney's friends suspected he was hiding something before they met his secret wife and son. The family may have been rooted in a lie but Barney had a good reason for their existence.
Throughout How I Met Your Mother's nine seasons, multiple members of the Stinson family were introduced. Barney had a gay, black half-brother named James (Wayne Brady) who he got along well with, especially since they both loved laser tag and nice suits. After going through life thinking his father was Bob Barker, Barney eventually learned that his real father was Jerome Whittaker (John Lithgow), giving him another half-brother named J.J. Whittaker (Will Shadley). Barney's most interesting relationship, however, was with his mother, Loretta Stinson (Frances Conroy).
In the season 4 episode "The Stinsons," Ted, Robin, Marshall, and Lily were worried about Barney after he exhibited odd behavior. To find out what he was hiding, the group followed him to a home in Staten Island. While there, they met Loretta, the owner of the home. But more surprisingly, they found out that Barney had a wife, Betty, and a son named Tyler. Barney, Betty, and Tyler acted as though they were a perfect little family, which was another red flag. After Loretta exited the room, Barney informed his friends that his wife and child were actors. Barney hired them years ago because of his mom.
Barney first hired Margaret (aka Betty) to pretend to be his fiancée when Loretta was very sick. There was a chance that Loretta was not going to survive her illness, so Barney took drastic measures to make his mother happy in what he thought was the end of her life. Margaret took the role a bit too far and blurted out that she was pregnant. After Lorretta miraculously got better, Barney had to keep the ruse going, so he hired Grant to portray his son.
The truth finally came out that night when Ted and Margaret were caught kissing in the kitchen. Barney came clean to Loretta and revealed the truth about his hired family. Loretta was ultimately relieved by her son's confession since she was never a big fan of Betty or Tyler. In the end, she just wanted what was best for Barney and convinced him that he will find love elsewhere. This gave Barney the courage to finally pursue Robin.
Barney and Robin did end up getting married towards the end of How I Met Your Mother season 9, but their marriage didn't last. They divorced just after three years and Barney returned to his womanizing ways. That didn't stop him from starting a real family later in the future. He got a woman pregnant and had a daughter named Ellie. It was unclear if Barney ever settled down with the woman, but Ellie truly changed his life for the better.