(15) Why did Hamas think attacking nuclear-armed and USA-allied Israel would be a good idea? - Quora
Desperation.
For years, the Arab states have been moving towards normalizing relations with Israel. Hamas counts upon the support of Arab states, both material and financial, to exist since it has very limited means of its own.
Normalized Arab-Israeli relations would be the coup de grace for Hamas and the “Palestinian liberation” movement. Because a precondition of normalized relations with Israel would be ceasing support to Hamas.
Part of the reason why Arab states were warming up to Israel was that Arab leaders have been losing faith in the Palestinian forces for decades now, and an improvement for the Palestinians was nowhere in sight.
Regardless of where you stand on this conflict, it's hard to argue that Palestinian forces have had much in the way of success recently (or ever, for that matter), having lost land to Israel almost continuously since Israel's inception. The reasons for this are not surprising. Palestine isn't really even a nation at this point, it's two paltry strips of impoverished land run by a corrupt elite and barely educated militants with no resources of their own. They are facing a prosperous, well-organized nation-state with a highly competent military and the direct support of the world's premier powers. It was never going to turn out well for them.
Whether you agree with the above diagram or not, it is what the Palestinians have always proposed as their version of what has happened to them. So even they admit their total failure against the Israelis.
And I suppose the Arabs were tired of tying their money up in so clearly a lost cause. Oh sure, they still outwardly broadcast support for Palestine for religious reasons and internal appeasement (most Arab Muslims are extremely against any rapprochement with Israel), but I suspect they have been planning a move away from being active stakeholders in the Israel-Palestine conflict for a while.
So why the attack from Hamas now? Well, it's an apparent attempt to sabotage the normalization of relations across the ME, which would have sounded the death knell for them. I cannot imagine the Hamas leadership would stand idle and let the war coffers they plunder empty out. So they attacked Israel, performing the attack in a way that would cause the most severe reaction from the Israelis. Massacring Jews, abducting Jews, the whole shebang! They were trying to force Israel into the largest possible retaliation against them (they might have succeeded), thereby forcing the Arab powers into taking a stance against said Israeli retaliation. That's my only explanation for this attack. Otherwise, the immediate tactical value of killing a few hundred Israeli civilians eludes me.
And it seems to have worked…for now.
Many of the Arab nations previously moving towards normalized relations with Israel have now performed a sudden U-turn, mostly for reasons of posturing (and possibly gaining leverage out of the situation). But I don't think this will last long. Some of the Gulf states didn't even openly side with Palestine this time, the UAE came out with this statement;
I imagine most Arab powers see that the writing is on the wall for Hamas. There is no possible way that, having poked the Israeli bear, Hamas can resist any Israeli counter-operation effectively. After all, the Israeli army is a world-class professional fighting force. At best, Hamas is a glorified militia fighting on very little land, wholly trapped and starved of supplies. Or, to be brief, they're f*cked.
I suppose once the Arab countries can extract some personal benefit/concession from the situation, they will perform another U-turn and return to ditching Palestine. I can see Saudi Arabia's shallow declaration of support for Hamas disappearing once the Saudis can get some security deal with the US in exchange for re-normalizing relations with Israel.
Regardless, the long-term outlook for Hamas is poor. They made a desperate, flailing attempt to “reunite the Ummah” and gain a [im]moral victory against Israel.
In time, I think they will come to regret it.
ADDENDUM:
This answer has covered the possible external motivations for Hamas's operation, but it's worth taking stock of the internal Palestinian political situation.
The President of the Palestinian State, Mahmoud Abbas, of the Fatah (فتح) party, is 87 years old, and has ruled the Gaza strip and the 167 islands of the West Bank since 2005. He is not going to live that much longer and has no clear political successor in his own party. Hamas is likely seeking an opportunity to seize power across Palestinian controlled territories by staging a grand morale victory against the Israelis. I suppose their plan was that this bold operation would give them a large political boost and the necessary support in Palestine and the Arab League to take over the reigns of power from Fatah.
And whilst the tactical situation for Hamas is kaput, the operation could be a political boon. Though what use that would be if the Israeli's conduct a ground offensive to destroy Hamas as a serious organization, is beyond me.