The soldiers were not engaged in combat or battle and so were not a legitimate military target. Hamas will never be "unnecessary" as far as the Palestinians are concerned as its objective is the complete elimination of Israel and its Jewish population, and ownership and control of the entire land from the River to the Sea.