Israel spent many decades ensuring Hamas held power in Gaza.
It ensured Hamas was well funded and able to arm itself to have control over Gaza. A terrorist organisation ruling over Gaza was a shared goal of Hamas and Israel's right wing government.
Hamas and Israel have always been allies.
That is because a strong Hamas would prevent the PLO unifying Gaza and the West Bank, paving the was for a single Palestinian state.
It's the old and reliable tactic of divide and conquer.
And it's much easier for Netanyahu to wage an aggressive war against Gaza ruled by a terrorist organisation than it would have been against a more secular and liberal PLO.
Netanyahu had been waiting for Hamas to do something to justify his full scale obliteration of Gaza.
It wouldn't suprise me if Israeli security forces knew of a planned large scale attack prior to October 7, but allowed it to happen because it plays into the desired endgame of Netanyahu and his hawks.
It only makes sense, after all, Israel ensured Hamas was powerful this allowing it to carry out such an attack.