The general criticism I've heard about Haley's pregnancy is that it seems shoe-horned in to ruin her character. "It ruins her career," "She ended up with her loser high school boyfriend," "they just got her pregnant young like her mom," etc. But none of that makes sense. Haley had a lot of different career paths but never stuck to one, which fits with her character. She did well with photography, her fashion blog, her promotional business, her fashion assistant job, the country club, etc. But she bounces around. It's not wrong and she does well in these things but consistency doesn't ever seem to be her thing. When she gets pregnant, she is working for an actress's sham "health" company. Granted, she calls it her "dream job" but who's to say she would have stuck to it for much longer? She hasn't in her past "dream" jobs. So I don't think her pregnancy derailed a promising career.
In the episode she founds out she's pregnant, she and Dylan are wrestling with the fact that they don't seem like mature adults. That's something Haley had struggled with throughout the show, especially when she's living in her parent's basement. Having kids gives her the stability that she lacked and also the reason to mature and have her own home and life.
Dylan isn't her loser high school boyfriend. He is putting himself through nursing school and is providing a good life. He's not a loser or idiot. He's a nurse. Haley herself laid out all the reasons she loved Dylan (the same reasons Claire loved Phil): she is find being herself around him, even when it's messy. She imagines a small home with lots of laughter. People constantly call back to Andy but I do think their relationship wasn't the best. The infidelity and constant cheating on both their parts were icky. Andy was literally engaged and they had a long affair, not a one-off hookup. Arvin was a good relationship but she didn't feel comfortable as herself. He made her feel dumb about herself, even if it was unintentional. Also, Haley is not a young mom (she is young but not a teenager nor in her early 20s) like Claire was. Haley is around 26 which seems a normal time to start a family.
In conclusion, I do think her pregnancy makes sense because becoming a mom actually made Haley come into her own. This starting of a family made her actually move out and have stability, which is something she constantly lacked in her careers.