To the choirmaster. This refers to the verse (Numbers 21:19), "From Mattanah to Nahaliel." Rabbi Yehuda says that from the wilderness they merited to receive the Torah through Moses, as it says (Exodus 31:18), "And He gave to Moses." From Nahaliel they inherited idolatry, and they said to the calf (Exodus 32:4), "This is your God, O Israel."

From the deaths in Mattanah they received the angel of death upon them, as it says (Numbers 14:35), "In this wilderness they shall die." From the deaths in the valley that they caused, the righteous one buried in the valley was affected. Jeremiah said to them (Jeremiah 2:23), "See your way in the valley." The Sages say that from Nahaliel they inherited to God as a deity and He inherited them as a nation.

From the wilderness they received the Torah. David said, "Since this is the case, I will sing of both to the choirmaster, to the inheritance." Another explanation is that instead of saying "from Nahaliel," one should say "from my inheritance, to God." Because of the well that God gave them, they would sing a song and they had the water [like a river] so that any woman who wanted to go from her father's house to her husband's house would go by boat.

And so David said (Psalm 107: 31-32) "Let them give thanks to the Lord for his steadfast love, for his wondrous works to the children of man! Let them extol him in the congregation of the people, and praise him in the assembly of the elders." The Assembly of Israel said: "Because the well was given to me as a gift, I inherited it." And thus it says (Lamentations 3: 24) "My portion is the Lord, says my soul."

God said to them, "I am your portion and you are my portion," as it says (Deuteronomy 32: 9) "For the Lord's portion is his people." David said, "Since this is the case, I will sing about my inheritance." Regarding inheritance, we only say "the inheritances" about the inheritance that you gave me and the inheritance that I gave you. And from where did we learn that they were given an inheritance from the well?

Before they drank from the well, what did they say? (Exodus 17: 7) "Is the Lord among us or not?" After they drank, they said (Exodus 24: 7) "All that the Lord has spoken we will do, and we will be obedient." We inherited you in two inheritances, and we inherited the Torah. And so David said (Psalm 119: 111) "Your testimonies are my heritage forever."

"And the land of beauty, My inheritance, as it is said (Jeremiah 3:19): 'And I gave you a beautiful land, the inheritance of the glorious hosts of nations.' What are the hosts which everything is hidden in them? It is similar to a king who sat at his table and had many sons, and he loved the youngest and gave him gifts, and they had one field and everything was hidden in it. He said to them, 'This is mine.'

Similarly, it says (Deuteronomy 32:8): 'When the Most High gave nations their inheritance.' To whom did He give His portion? To His small child. So too Jacob inherited his portion.

And it is written (Amos 7:2): 'Who will rise up for Jacob, for he is small?' Even the Temple is an inheritance, and so it says (Numbers 24:5): 'How good are your tents, Jacob, your dwelling places, Israel.' And how beautiful are they, like streams that branch out. Just as a person descends into a stream impure and emerges pure, so too the Temple is entered with sins and exited without them.

And so Moses says (Deuteronomy 12:9): 'For you have not yet come to the resting place and the inheritance.' The resting place is the land, and the inheritance is the Temple. David said, 'All that You have given us is good and pleasant,' as it says (Psalm 16:6): 'The lines have fallen to me in pleasant places.' And so it says (Micah 7:8), "Do not rejoice over me, my enemy, for I have fallen but I will rise again.

If I sit in darkness, the Lord is my light." The Holy One, blessed be He, said to them, "You have justified yourselves in the judgment, and I will call you (Isaiah 61:3), 'Eliezer, the righteousness of the plantings of the Lord, to glorify.'"