Why did Avraham Avinu care if the people of Sedom would be wiped out if they were resha’im anyways? Why did Avraham care so much?
Because Hashem cared. Hashem doesn’t want people to be killed. “Mai’sah yodai toiv’im ba’yam, vi’atem omrim shira?” [Megillah 10b] Hashem made people and every human is a precious thing – a precious gem. And therefore Hashem doesn’t kill people so readily.
And so, when Avraham Avinu prayed for Sedom he was imitating Hakodosh Boruch Hu. Avraham dedicated his whole life to trying to imitate Hakodosh Boruch Hu as much as possible. He saw that Hashem had created a world of chesed so he dedicated his life to doing chesed. And therefore, when Hashem threatened to destroy Sedom, he let Avraham Avinu know about it because He wanted to give Avraham the opportunity to gain greatness by asking for their favor and trying to protect them. Only that Hakodosh Boruch Hu said that despite the mitzvah that you did by praying for them – it’s not enough. It wasn’t enough because the people of Sedom were “ra’im va’chata’im la’Hashem me’od.”
And therefore Avraham Avinu was doing exactly what Hashem expected him to do when he prayed for them. He succeeded at this test and became even more perfect than he was before. Only that despite the fact that he did pray, Hakodosh Boruch Hu said, “I’m going to carry out this decree anyways.”