This must be so hard for you - and the last thing you need with a small child, and a baby on the way.
As to what you said - "I can't understand why" - that bit is actually not difficult. Understanding the Why is easy. Moving past, forgiving and re-building the relationship is the hard bit.
There are many reasons people cheat. Most of those are about them, not the relationship, and not their partner. You have been together for 6 years - and in those times had a baby, and multiple losses. It's a lot for any relationship to deal with, and certainly in such short period of time.
Men and women are different on so many dimensions. We, women, like to imagine that when paired up and going through getting pregnant, etc - men are on the same page with us, and think like us. But they are not us.
While we become singlehandedly focused on getting pregnant; or our emotions about pregnancy loss; and about trying again - they are supporting us, but they are not feeling the same as us. And they do often end up feeling like they lose their place in a relationship as a partner - and baby, or trying for it, overtakes in importance. And some - like your H - have trouble dealing with it.
This is the Why.
I am not excusing any of it. Men are weaker species than us, and they are, at their core - very selfish, and they do struggle putting themselves last for any period of time. Some are better at keeping it in check, many more are not.
As to what you do with this all now - it's really up to you. And I'd also say it's up to the support network you have, as your life is about to become a lot harder - after your 2nd child is born.
People make mistakes, and it is not impossible to move forward from this - if you decide that this is best for you and your family. Most marriages do not break down after infidelity - according to marriage councillors.
And equally - some people do break up and co-parent.
Given the age of your child and upcoming baby - I'd probably be pragmatic and let him be around to help. And I'd decide what to do about the relationship later, once through the hardest bits, in whichever way you define it.
Or - if you have a good support network and don't need his help - I'd give myself as much time as necessary to decide.