Because it’s a genocide. The point isn’t to just take out Hamas and say “mission accomplished”, it’s to take out the entirety of Palestine and say “we tried our best to save them”. Hamas has to continue existing in order for Israel to keep justifying every extension to this war.
If I had to guess, I’d say funding and plausible deniability are the big reasons. The longer the war wages on, the longer the US and other allies keep sending them money and weapons. And killing them off slowly makes it easier to argue to the ICC that you weren’t trying to commit genocide, it just kinda happened as an oh-so-unfortunate side-effect of defending themselves.