This example fits the context by showing that the authoritative words of Jesus interpreted and fulfilled the Old Testament law.
Anyone who divorces his wife and marries another woman commits adultery: The Old Testament allowed divorce but did not approve of it (Deuteronomy 24:1–4). In the time of Jesus, Jewish teachers debated what counted as valid grounds for divorce. The school of Shammai taught that a man could divorce his wife only for sexual unfaithfulness. The school of Hillel allowed divorce for almost any reason.
Against this casual view of marriage, Jesus taught that divorcing a spouse and marrying another person was equal to committing adultery. In other passages (Matthew 5:32; 19:9), Jesus gave a clear exception for cases of unfaithfulness.