They have a right to defend themselves. They wouldn't have been treated as nicely as they've treated Gazans if the roles were switched. Hamas decided to attack people who were so merciful to them when they wouldn't have shown such mercy.
Of course nothing good will come of this discussion, but let's try.
Israel was created by western powers and has slowly taken over the land over the past 70 years, forcing Palestinians into smaller and smaller areas until eventually they're just forced into Gaza. The population density in Gaza is higher than Tokyo, just without anything that would allow for them to live dignified healthy lives.
The conflict is entirely one-sided, considering Israel has the backing of US military. Israel is commiting war crimes daily, such as using white phosphorus bombs on civilians, which burn the targets down to the bone.
They justify this by calling the Palestinians subhuman animals and utilize many of the same fascist tactics that Nazis used against Jewish people. They hide behind the idea that if you criticize them then you must be anti-Semitic, as if Zionism has any place in our world.
Another motivation here is when Israel went to war with Egypt in 2006. Their main goal was to assert dominance in the region so other countries wouldn't try to mess with them, and they lost horribly. The current situation is just Israel retaking an exam that they failed the first time with an answer key.
Imagine if someone broke into your home 70 years ago and no one stopped them. Over time, they pushed you further into your home while you were just trying to exist peacefully. Now it's at a point where you, your grandma, your parents, cousins, aunt, and children all live in the closet together and you're not allowed out to go to the bathroom or use the kitchen or anything. Your cousin takes a swing at the guys who broke into your home, and now people online really think there's a debate about whether the intruders "have a right to defend themselves."
Israel has now existed for nearly a century. Several generations. Therefore, to say something like that today is a gross denial of reality. It doesn't help anyone.
You know, your statement has honed in on the very heart, the very crux, of this debate. It's how most people are approaching it, as a "deserve" consideration.
There are, incidentally, other ways of looking at it, asides from some worthy-ness perspective. Could it be possible that nobody is worthy? Or that each historical side has both worthy and unworthy people on it, instead of all being the same?
The powers that are in the middle east have no chance of peaceful cooperation or even peaceful coexistence. Divide it up and make it a protectorate of Japan, Ireland, and Mexico for all I care. They'd certainly run it better and there's no millennia of history and ghost stories keeping them at each other's throats like the current rulers.