You seem to have your finger on the issue, its your confidence in yourself. I am sorry that you are going through something that makes the most confident of us have self doubts.
I don't know your husband, but I do think you are being way too understanding of him right now. When you marry someone and especially when you have kids with them you're taking on a responsibility to help grow with each other, cutting and running is not the way to do it. When you were gaining weight, was he going to the gym with you? I'm only saying this because to truly feel confident in yourself you need to like the person you are. If you rationalize and understand all his reasons for putting you through this you are basically telling yourself that you deserve it.
No you don't deserve it. He is lucky to have you. These are the things you need to start telling yourself. Become the person you want to be (not what you think he wants you to be). If you can do that then you will be stronger, and your kids will be stronger from your example. Whether your husband benefits from your self-improvement remains to be seen. It does take time, and there are set backs, just keep focusing on being the person you want to be and you will end up finding yourself surrounded by people who like you for who you are and the confidence will come.