It was all just a dream; he never settled because he's too picky. He regrets never having kids and made the entire thing up killing time on his death bed.
I could see it all being a dream that causes Ted to come up with a reason to break up with the mom early in their relationship. I haven't seen the past 2 seasons so my ending could be impossible.
People have suggested it is something he recorded before he died since he likes telling stories and wouldn't have the chance to tell his kids. I think that theory was shot down though because apparently he interacted with the kids in one of the early seasons.