In the Old Testament divorce was legal and remarriage was expected in most cases. The priest and high priest could not marry a divorced woman (Lev. 21) and a man could not remarry the wife he had divorced after she had been married to another man (Deut. 24:1-4).
This was the Law of Moses, so it came as a shock to many people when Jesus suggested that in God's view, you might live according to this law and still be sinning against God and against your spouse.
Consider Jesus' teaching in Matthew 5.
(Matthew 5:17 NKJV) ¶ “Do not think that I came to destroy the Law or the Prophets. I did not come to destroy but to fulfill.
Jesus goes on to say that not even the smallest stroke of the Law will pass away until it has all been fulfilled (v.18). But in his exposition of various commandments from the law (e.g., murder, adultery, vows, love for neighbors, etc.) he teaches that even if we have obeyed the letter of the law (like the scribes and Pharisees in verse 20) we may still have violated the spirit of the law and practiced unrighteousness in God's sight.
We might be tempted to say, "I'm right with God because I have not murdered anyone." But God, looking at our hearts sees our selfish disregard for the people around us. Our biting sarcasm, character assassination, ranting verbal attacks and revenge fantasies are all the same kind of sin to God as murder is. We may have not technically committed murder, but we are murderers.
In the same way, adultery is defined as having a sexual relationship with someone other than your spouse - or with someone who is married to someone else - not you. You are polluting (adulterating) someones' marriage relationship.
Since they had the legal recourse of divorce, it seemed to people that they could avoid violating the letter of the commandment against adultery by divorcing their current husband/wife before having a relationship with a new husband/wife. But Jesus says:
“You have heard that it was said to those of old, ‘You shall not commit adultery.’ But I say to you that whoever looks at a woman to lust for her has already committed adultery with her in his heart. (Matthew 5:27–28)
"...it has been said, ‘Whoever divorces his wife, let him give her a certificate of divorce.’ But I say to you that whoever divorces his wife for any reason except sexual immorality causes her to commit adultery; and whoever marries a woman who is divorced commits adultery. (Matthew 5:31–32)
Jesus is not here rewriting the letter of the law and invalidating legal divorces and remarriages. Jesus is saying that the widespread practice of divorce and remarriage is a testimony to the adultery brewing in people's hearts. A man divorces his wife because he is already committing adultery against her in his heart.
So He said to them, “Whoever divorces his wife and marries another commits adultery against her. And if a woman divorces her husband and marries another, she commits adultery.” (Mark 10:11–12)
A man may look at a woman without committing adultery with her in his heart. There is a legitimate situation where divorce is allowed and is not based on adulterous motives. (Joseph's plan to divorce pregnant Mary was evidence of his righteousness in Matthew 1:19.) But the eyes and the provisions of the law can be (and often are) used for sin.
(Proverbs 4:23) Keep your heart with all diligence, For out of it spring the issues of life.