Could you comment on which sorts of immorality the school of Shammai believed were covered by Deut. 24:1, but not by Deut. 22:22? Dead people don't get divorced, so did they have a different category of indecency that wasn't adultery?
Reply: You are right to point out the potential contradiction between Deut.24.1 (which talks about divorce for "a matter of indecency") and Deut.22.22 (which says an adulterer must die). If there was a death sentence for adultery, how could anyone get divorced for adultery?
There are various potential solutions for this contradiction. Perhaps the law of Old Testament was already changing during OT times - after all, Nathan did not call for Bathsheba's death. Or perhaps "a matter of indecency" was something less than adultery? The precise meaning of Deut.24.1-4 is something which scholars are still looking into, and I haven't seen any fully convincing explanation of what the original case law was about.
By New Testament times the Jews had lost the authority to carry out a death penalty for adultery or any other matter (see John 18:31), so they said that it was compulsory to divorce a woman for adultery. Although they cited Deut.24.1 as proof of this, they were, as you point out, not using Scripture entirely in its context. And they were certainly wrong to say that divorce was commanded by Moses.
Jesus corrected them on two counts - he said that Moses didn't "command" divorce for adultery (or for any other cause) but he only "allowed" it, and only when there was hardheartedness (ie stubborn and unrepentant breaking of marriage vows).
Secondly Jesus cited the words of Deut.24.1 very accurately by using the general Greek word "porneia" - a term which is used in the NT for adultery, prostitution, fornication, incest and for sexual sin in general. Jesus didn't make the mistake of translating it "adultery" (according to Matthew).
Jesus didn't tell us what exactly his interpretation of Deut.24.1 was, except to say that he disagreed with the Pharisees who found two types of divorce: the 'any cause' divorce and 'divorce for adultery'. Jesus said that Deut.24.1 referred to only one type of divorce, for 'a matter of indecency' (porneia), so that anyone who got divorced for 'any cause' had an invalid divorce.
So you are right to point out the potential contradiction between these two verses. As you can see, Jesus' interpretation did not fall into the same mistakes as the Pharisees.