They say unto him, Why did Moses then command to give a writing of divorcement, and to put her away?
Note 5 at Mt 19:7: Instead of a simple answer explaining scriptural grounds for divorce, Jesus had stunned the Pharisees with the revelation that divorce was never intended by God (see note 10 at Mr 10:2). This led the Pharisees to ask then why Moses gave instructions for divorce. Once again, this was not an honest question on their part, but they were trying to entangle Jesus in His talk.
Jesus answered that divorce was permitted but never intended. God allowed something that He hated (Mal 2:16), because of the hardness of people's hearts (see note 10 at Mr 6:52). This was also true of polygamy (see note 11 at Mr 10:6) and slavery. Jesus came to remove our stony hearts and give us hearts of flesh (Eze 11:19) so that we could walk in God's best for us.