They're a symptom, not the problem. As fucked up as Hamas is, they're inherently a liberation movement of a oppressed minority. If Hamas were gone, some other group would take power. Either that or Israel moves even further towards dictatorship and maybe commits a little bit of genocide on their own, but I would at least expect a full annexation of those territories. It's an incredibly complicated and fucked up situation.