It is legitimate for any sovereign country to wish to fully destroy a terrorist group that threatens their national security, especially when they're proxies of another country such as Iran.
But it is not legitimate for any terrorist group to try to destroy any sovereign country.
So where does that leave Palestinians in Gaza? They and their homes, lives, schools, hospitals, society is currently getting destroyed, is that legitimate in Israels legitimate campaign to destroy Hamas?