A mistake? The Israelis didn't understand the extent to which Hamas views itself as engaged in a holy war. They (and many others, including me) thought that Hamas would prioritize building Gaza and providing services to its people over murder/kidnapping raids.
You're underestimating how valuable Hamas has been to the Israeli right. Smotrich called them an asset in 2015 for a reason, and Netanyahu said similar in 2012.
With Hamas in charge, Israel could avoid making new peace agreements or concessions by saying that there was "no partner for peace". The more violent Hamas got, the more cover Israel had for expanding settlements. And now Likud is already talking about what they'll do with all the Gaza land they're taking.
That's one theory. Another one is read the article.
The reason it matters is that under the second one Israel has no moral legitimacy, so saying things like moral imperative show how fucked up your morals are.