I think that what’s going on in the minds of those calling the shots on Israel’s side (or at least most of them) is: they’re not trying to level Gaza. They’re trying to fight a war against Hamas, and Hamas is fighting from positions in cities that are often literally on the grounds of or inside what ought to be protected civilian sites: hospitals, mosques, etc. And they are surely making what seems a straightforward tactical calculation: they could send infantry in to try to minimize civilian casualties at enormous cost to their infantry, or they could use their massively superior firepower to just destroy the Hamas positions from a distance.
And the Israeli command feels the need to fight on the ground in the first place because Hamas is holding obviously innocent hostages and shooting militarily-useless but nonetheless quite dangerous explosive-filled rockets over the border. Hamas is goading them very effectively. If Israel could magically snap its fingers to destroy Hamas, get rid of all of Hamas’ weapons, and leave Gazan civilians, buildings and infrastructure alone, of course they would!
One might ask why Hamas is doing any of the above. I don’t think Hamas is at all on the side of the residents of Gaza. Their strategy seems much better explained by some rather different goals: improving their own status in the world, raising money, making a really big show, weakening Israel, seeming and feeling important, and recruiting more militant members. I think that every Gazan civilian injury and death is in Hamas’ favor. Israel making itself look bad is in Hamas’ favor. More Gazans who hate Israel and feel hopeless and marginalized is in Hamas’ favor. So of course Hamas wants to keep holding hostages and randomly blowing stuff up in Israel.
To be clear: I do not think Israel is making an ethically or strategically appropriate decision here. But I understand where they’re coming from.
And I don’t think Hamas is making the right decisions either, ethically or strategically, at least if the goal is making a good, safe life for residents of Gaza.