It’s been pointed out repeatedly that Ted Mosby, nominal protagonist of How I Met Your Mother is the least likable person on the entire show, since at least the third or fourth season. He consistently makes terrible decisions, ones we simply groan at, and ones we simply can’t forgive him for (like the fifteenth time he tries to win Robin back). He is an infuriating character.
But we also need to remember that he is a demonstrably unreliable narrator. On occasion he mixes stories up entirely, shifting them forward or backward entire seasons, having to correct himself as he’s telling the story. And add to this one more element: this is not a story that he is telling to the fourth wall, not just some bit of first person perspective forced onto the show. The decision was made from the very beginning to have him explicitly be telling this story to his teenaged kids. This frame isn’t just a conceit, it’s to set up the motivation for these tales in the first place. Because we change our stories based on who our audience is, even unconsciously.
This is put right in our faces from the very beginning with the substitution of “sandwiches” every time someone is smoking pot. On one level this is just a joke, a funny hang-up he has with what he wants to talk to his kids about. But on a second level, it’s a nudge at us to remember that the story changes with the storyteller. And Ted over and over again engages in dramatic over-exaggeration of the adventures of he and his friends.
We can surmise by reading between the lines that Ted is a genuinely sweet and good guy. But in his own stories about his past, to his children, he consistently displays himself as making terrible decisions and sort of being a douchebag for long swathes of the story. You know what assholes do when they tell stories? They make themselves the center and exaggerate everything they did (exhibit A: everything Barney ever says). What do good guys do? They put themselves to the side. Ted is not the main character or even most sympathetic character in his own stories exactly because he’s a good guy who is worth listening to. And what do good guys with a side helping of humility do? They exaggerate everything they ever did wrong. Especially if they are trying to share their past with someone who they care about.
Ted might be insufferable for big parts of the story, but it’s never done with a celebratory note, he is actually intentionally describing himself as insufferable to his children. That’s what people, good people at least, do in their moments of confession. Teddy Westside might be insufferable, but the Ted telling this story? He is warning his children off of all his mistakes, of all the ways he screwed up his life, so that maybe they can avoid those same missteps.