It had been written by Moses {Moses had written} long ago in a law that God gave him, that when a woman gave birth to her first son, the parents had to take him to the Temple in Jerusalem in order that they might dedicate him ◄to the Lord/to God►. So when the time came for them to do those rituals so that God would consider them pure again, Mary and Joseph took Jesus there.