Jesus was teaching the new covenant and its law to sons of Abraham who were yet under the old covenant and it's law. So it was right that he told them to obey the old covenant law of Moses as long as it was in force, ie, until all righteousness was fulfilled.
All righteousness fulfilled
Seventy weeks have been determined upon thy people and upon the holy city for sin to be ended, and to seal up transgressions, and to blot out the iniquities, and to make atonement for iniquities, and to bring in everlasting righteousness, and to seal the vision and the prophet, and to anoint the Most Holy. Daniel 9:24