Joseph and Mary took him to Jerusalem to present him to the LORD, as it is written in the LORD’s Torah: “Every first-born male is sanctified to the LORD.” (Luke 2:22-23)
Luke 2:22-39 describes the “redemption” of Jesus in accordance with Exodus 13:2,13, which commands that every first-born male Israelite be redeemed because his service belongs to the LORD. Luke also adds that Mary went to Jerusalem to sacrifice the prescribed offerings after giving birth: “a pair of doves or two young pigeons” (Lev. 12:8).
According to Jewish religious law, it is not necessary to go to Jerusalem in order to redeem a first-born son. The ceremony, פִּדְיוֹן הַבֵּן (pidyon ha-ben, redemption of the son), can be held anywhere and the redemption money is included among those gifts or offerings which are given to priests any place in the land of Israel:
Twenty-four priestly gifts were given to Aaron and his sons… ten in the Temple, four in Jerusalem and ten anywhere in the land of Israel… [and among those received by the priests anywhere in the land was] the redemption of the first-born son.” (Tosefta, Hallah 2:7-9)