Jesus and the disciples did not violate divine law. They broke with the uninspired traditions of the Jews, but they did not break Biblical law.
Christ said that David’s eating of the showbread was unlawful. He did not endorse the unlawful act.
He was demonstrating the inconsistency of the Pharisees by pointing out that David broke the law of Moses, but they did not condemn him for that. Yet, when His disciples violated their human traditions (the law of God did not forbid them from plucking and eating the grain on the Sabbath), the Pharisees were charging His disciples with sin.
Jesus was without sin. He could not (and would not) have condoned breaking the law, otherwise He could not have been that perfect sacrifice and atonement for our sins.