What reasons does the Bible give for why the tribe of Levi was chosen to have the priesthood and temple duties? What reasons does the Bible give for why the tribe of Levi was chosen to have the priesthood and temple duties?

In Genesis 49:5-7 when Jacob was telling his children what will happen to them, he told Simeon and Levi that they were violent and that they would be scattered among the descendants of Jacob and they would be dispersed among Israel. Could this have been something like a prophecy and could this be the reason?
Audrey's answer is correct, and here is the quote. The Levites remained loyal and restored order when the people were worshiping the Golden Calf. They killed 3,000 of their fellow Israelites, which set them apart.

19 When Moses approached the camp and saw the calf and the dancing,
his anger burned and he threw the tablets out of his hands, breaking
them to pieces at the foot of the mountain. 20 And he took the calf
the people had made and burned it in the fire; then he ground it to
powder, scattered it on the water and made the Israelites drink it.
21 He said to Aaron, “What did these people do to you, that you led
them into such great sin?”
22 “Do not be angry, my lord,” Aaron answered. “You know how prone
these people are to evil. 23 They said to me, ‘Make us gods who will
go before us. As for this fellow Moses who brought us up out of Egypt,
we don’t know what has happened to him.’ 24 So I told them, ‘Whoever
has any gold jewelry, take it off.’ Then they gave me the gold, and I
threw it into the fire, and out came this calf!”
25 Moses saw that the people were running wild and that Aaron had let
them get out of control and so become a laughingstock to their
enemies. 26 So he stood at the entrance to the camp and said, “Whoever
is for the Lord, come to me.” And all the Levites rallied to him.
27 Then he said to them, “This is what the Lord, the God of Israel,
says: ‘Each man strap a sword to his side. Go back and forth through
the camp from one end to the other, each killing his brother and
friend and neighbor.’” 28 The Levites did as Moses commanded, and that
day about three thousand of the people died. 29 Then Moses said, “You
have been set apart to the Lord today, for you were against your own
sons and brothers, and he has blessed you this day.” (Exodus 32:19-29)

You are also correct about Genesis 49:5-7 being relevant. This was the time when their violence served the Lord, and the curse upon them was turned into blessing. They received no inheritance of land, but instead inherited the priesthood.