Sparing the Wicked
Rivkah: In Egypt, the Egyptians would punish the Jews if they did not produce their quota of bricks by taking their babies and putting them in the wall they were building to fill in where a brick should have been. When the question was asked by a Jew why Hashem allowed this, Hashem answered that He permitted this because if the baby was to live he would be a rasha – an evil person But, when Ishmael was sent out of Abraham's house by Sarah and the angels told Hashem that he should not be saved because he would be destroying the Jews in the future, Hashem answered the angels that He would judge Ishmael on his "current" sins and merits, not on what would happen later on.
There is a conflict there...why?
Rabbi: God didn't kill the Jews in Egypt, the Egyptians did. So there's no question about God killing them due to their latter end. God merely didn't step in to save them. God was inactive. A Rabbi taught that those Jews were idolatrous and deserved this fate. Rashi agrees, stating that four fifths of the Jewish population were killed in the Plague of Darkness. Evidently, that Jewish population was corrupt beyond repair.
In the case of Ishmael God did perform salvation based on "As he was there" ("ba'asher hu sham" – Gen. 22:17) meaning Ishmael's current status as righteous. Thus, he was not deserving of punishment, but salvation. Rashi (ibid) records your cited medrash that the angels asked God that since Ishmael's descendants would pain the Jews, why save Ishmael?
So why did God determine Ishmael should be saved, while the Jews in Egypt should not be saved? Was there not inevitable evil God could thwart in Ishmael's case too? So why treat Ishmael differently and save him, while letting the infants die?
One difference is that in Egypt, it was inevitable that the very infant would have become an evil person, so saving him would be futile. But Ishmael was not the one who would perform the evil in the future – it was his offspring.
A second difference – located in the Rashi above – is that Ishmael was now over 13 (Gen. 17:25) and he had merits. Whereas an infant has no merits. There was no claim of righteousness that could have been used to defend those infants, but regarding Ishmael, he already matured and made righteous decisions, thereby earning him God's providence. So God saved him.
"As he was there" ("ba'asher hu sham") – meaning judging one on his current merits – is applicable only to Ishmael and not to the infant Jews in Egypt.
But what is truly strange, is why the angels asked God to let Ishmael die, based on the sins of Ishmael's descendants! Don't angles know the truth, that Ishmael was righteous at that point in time? And don't they know Torah...that God only punishes a man for his "own" sins? (Deut. 24:16) How then can they consider Ishmael to be at fault an deserving of death?
Rabbi Joshua Maroof: Perhaps judging a person is "baasher hu sham" but Hashem's judgment is also with reference to his ultimate plan for humanity's development, in which case the fact that descendants will be bad does greater damage to the overall hashgachic plan than destroying the innocent yachid would (this was the "hava amina" of the malakhim).
Rabbi: Well said Josh. Rabbi Israel Chait said the same idea regarding Moses killing the Egyptian. Rabbi Chait quoted Yonasan ben Uzziel, that Moses "looked here and there" - meaning Moses looked with divine knowledge to determine if a penitent or converted man would issue from this Egyptian. But Moses saw no good progeny, and therefore he killed him due to his sin.
Rabbi Joshua Maroof: There does seem to be a difference. Moshe was looking for a reason to exonerate a sinning person and exempt him from punishment based on his unwitting instrumentality to a greater good. In the case of Ishmael he was righteous at the moment and this would have been referencing the future to indict somebody innocent. This is also what hazal say about Hizkiyahu, that he didn't want to have children because he knew they would be wicked in the future and Yeshayahu told him we base our actions on the current halakhic obligation, nothing else.
Rabbi: Excellent answer. In fact, both cases are consistent with the concept of "V'hitz-diku haTzaddik", a mandate to seek justice more than guilt. So to sum it up, when seeking to exonerate, we go to the far reaches of God's ultimate knowledge of one's progeny or perhaps all areas than can acquit (Moses' case) but when indicting, we wish to dismiss any evidence of wrong in one's progeny (Ishmael's case). Why then did the angels suggest to rely on God's ultimate knowledge, and indict Ishmael due to his progeny? Perhaps this is because angels, as created being, have distinct missions and govern only those laws limited to their natures. The Rabbis teach, "One angel does not perform two missions". (Rashi, Gen. 18:2) For an angel to be merciful, would mean it would not follow its nature. This is something only God can do. Thus, God was merciful to Ishmael. The angels could not be so.