In a small nutshell, the idea behind all laws of war is to attempt to limit the warring activity to the warriors on each side, and no-one else. Sometimes - on Iwo Jima, or in the Sinai - this isn't so hard to do since there are no civilians anywhere nearby, but even then there are nuances such as the way prisoners and the wounded are treated. Most wars, however, aren't like that. Indeed, just about all wars are ultimately about things that will happen to civilians once one side has won and the other side lost. So on that level, the laws of war are guidelines, not rules that can be followed meticulously in any real sense.
But they are important rules, and you can often (not always!) tell which side is the "better side" in a conflict by measuring the attempts each side makes to adhere to them. (This is a concept totally foreign to approximately 100% of war reportage and punditry in today's media, but is no less true because of this).
The attempt to play according to these rules is what has Israel allowing humanitarian aid into Gaza these days. And the fact that the Palestinians take advantage of this so as to break the rules is, as we all know, to be expected.
Or do we all know? Or is it only those of us who are paying attention, AND are interested in facts as distinct from propaganda, AND are remembering what we're seeing - all in all, a very small group?