In a roadside motel on the way down to Mitzrayim Moshe Rabbeinu was almost killed because he didn't give his son a Bris Milah. He was on his way to do the great mitzva of rescuing the entire Jewish nation. Why didn't this mitzva protect him?
The Meshech Chochma asks how can Moshe do something so seemingly irresponsible like bring his wife and children with him to Mitzrayim? He answers that Moshe was still not confident that the Bnei Yisroel would believe what he was going to tell them. He therefore brought his family to prove that Hashem was taking them all out of Mitzrayim or else he wouldn't dare bring his own family to get stuck there as well.
His family's coming to Mitzrayim was a continuation of his lack of faith in Bnei Yisroel's emunah. If not for this lack of emunah his son would not be on the trip with him in the first place. Therefore the mitzva of redeeming Bnei Yisroel could not save him.