Why does it say that Jesus “learned obedience”? (Hebrews 5)
The context of Hebrews 5:7 makes it clear that “who, in the days of His flesh” refers back to Christ, the main subject in v. 5.
In Gethsemane, Jesus agonized and wept, but committed Himself to do the Father’s will in accepting the cup of suffering which would bring His death (Matt. 26: 38–46; Luke 22: 44, 45).
Anticipating bearing the burden of judgment for sin, Jesus felt its fullest pain and grief (Is. 52: 14; 53: 3–5, 10).
Though He bore the penalty in silence and did not seek to deliver Himself from it (Is. 53: 7), He did cry out from the agony of the fury of God’s wrath poured on His perfectly holy and obedient Person (Matt. 27: 46; 2 Cor. 5: 21).
Jesus asked to be saved from remaining in death, i.e., to be resurrected (Ps. 16: 9, 10). “Though He was a Son, yet He learned obedience by the things which He suffered” (v. 8).
Christ did not need to suffer in order to conquer or correct any disobedience. In His deity (as the Son of God), He understood obedience completely. As the incarnate Lord, He humbled Himself to learn (Luke 2: 52).
He learned obedience for the same reasons He bore temptation: to confirm His humanity and experience its sufferings to the fullest (2: 10; Luke 2: 52; Phil. 2: 8). Christ’s obedience was also necessary so that He could fulfill all righteousness (Matt. 5: 13) and thus prove to be the perfect sacrifice to take the place of sinners (1 Pet. 3: 18).
He was the perfectly righteous One, whose righteousness would be imputed to sinners (Rom. 3: 24–26). “And having been perfected, He became the author of eternal salvation” (v. 9). Because of the perfect righteousness of Jesus Christ and His perfect sacrifice for sin, He became the cause of salvation.
True salvation evidences itself in obedience to Christ, from the initial obedience to the gospel command to repent and believe (Acts 5: 32; Rom. 1: 5; 2 Thess. 1: 8; 1 Pet. 1: 2, 22; 4: 17) to a life pattern of obedience to the Word (Rom. 6: 16). —-John MacArthur
I went through Hebrews 5 once and now I'm trying to remember what I found?

I note that your question sates "why does it say"; now "how did Jesus learn" or "why did He learn"?
So; why does it say...? Because it's trying to tell us something.
(Yeah, thanks captain obvious!)
The word "learn" in Hebrews 5:8 means to acquire understanding through experience. The word "know" (Adam knew Eve.) often portrays an intimate knowledge of something. (Not necessarily sexual, but experienced of the soul none the less.)
The beginning of chapter 5 speaks of the high priest offering sacrifices for sin; his own included. Yet Jesus having no sin had not that necessity. Passages from the Old Testament describe Messiah's experience of atonement being that God had not "left his soul in hell" on account of God's just character forbade Him from condemning a "man" who was guiltless of personal sin.
Now the concept of God suffering His own wrath (being forsaken) to atone for sinners is kind of hard for us to wrap our brains around. Yet Jesus the sinless God/man forsaken of the Father and Spirit to atone for human sin was exactly His/his experience of suffering. He "learned obedience" "even unto death" (manifest as) "death on a cross". He/he obeyed "the plan" (that determined in eternity) to the utter destruction of His/his own personhood.
Since God is an immortal entity; I've come to the conclusion that what actually killed Jesus was the renting of the Divine nature from the human nature. His human soul had already been consigned to Sheol / hades for the purpose of the determinate of the Divine to accomplish the remainder of the atonement by the death of the flesh. His Divine will that drove the sinless human will to obey the Father unto death. The culmination of having learned obedience being that death.
(Am likely rambling a bit here now); but God not having the experience (at least as a created entity "in the flesh") of what it mean to obey now had that learning through the incarnation; even though an aspect of His/his person possessed all wisdom and knowledge. The full extent of that Divinity was hid from His/his own understanding / experience through the limitations the flesh circumscribed His/his existence too. This is what made Him/him an appropriate sacrifice; that He/he had no advantage over the first Adam in the scope of His/his humanity.
I think "learning obedience" was a process He/he accumulated through the entirety of His/his whole life. Isaiah 52 and 53 speak of Jesus being despised and forsaken of men, a man of sorrows etc. and those passages imply the scope of his entire life; not just his death.
Isaiah's Description
Isaiah 53
2 For he shall grow up before him as a tender plant, and as a root out of a dry ground: he hath no form nor comeliness; and when we shall see him, there is no beauty that we should desire him.
3 He is despised and rejected of men; a man of sorrows, and acquainted with grief: and we hid as it were our faces from him; he was despised, and we esteemed him not.
4 Surely he hath borne our griefs, and carried our sorrows: yet we did esteem him stricken, smitten of God, and afflicted.
5 But he was wounded for our transgressions, he was bruised for our iniquities: the chastisement of our peace was upon him; and with his stripes we are healed.
So, here's the first set of verses in our English translation; but what do these passages actually "look like" in the Hebrew?
(Pun Intended!)
Interestingly enough, these verses actually don't have anything to do with Jesus's physical description. They actually have to do with people's perception of him in the role he came as; Messiah, "suffering servant" and King!
Let's break it down:
Verse 2:
First off "he shall grow up" is a Hebrew tense that is an incomplete action. (He's never going to stop "growing up"; which doesn't make any sense in English, but when we translate the rest of the verse, it will make more sense.)
"as a sapling in the face of Him (God); as a root which originated all the way down at the foundation (not getting it's nourishment from the dry ground around it)."
"...which has no..." The Hebrew word "no" in this verse is most often translated as "nor", then "can not": thirdly most translated as "no", "never", "not", fourthly as "without" and then "surely".
"form"; which this word is derived from a root word meaning "inclination toward".
"honorable", "majestic", "respected" or "splendorous" - "adornment".
"That when we see / saw / looked upon him, there were no attributes (of physical, charisma or any other "qualification") that would cause us to be pleased with; (as in desire to exalt or praise) him.
Now the next verse explains "why" (or rather people's perception of him based primarily on life circumstance.
Verse 3:
"He is dismissed with contempt, (looked down upon, marginalized) and refused, (ignored and forsaken) by men. A man who'd been inflicted upon with / sickened (emotionally) by painful suffering; (intimately) familiar with hardship. Of whom we hid our faces from, dismissing with contempt and not thinking of or considering him."
Verse 4:
Yet in all truth, our hardships he has taken upon him and that which pains our souls, he has lifted the heavy load. Yet we ourselves reckoned (thought of, concluded) him to be struck down defeated and cursed by God; contending with his frustration.
Verse 5:
But his heart was pierced and emptied because of our rebellion. He was crushed to contrition on account of being punished for our guilt, the correction of our welfare being secured was laid up against him; buy his chastisement we are made completely whole.
He shall continue to spring up as a sapling in the face of Him, as a root in dry ground nourished from the Foundation; surely never with an inclination toward honored majesty. For when we see him, we recognize no qualifying attributes we would desire to exhalt him for.
He is dismissed with contempt and ignored by men; a man who's soul has been inflicted with suffering and is well aquatinted with hardship. Of whom we hide our faces; dismissing him with contempt and not thinking to want to be considering him.
Genuinely, our hardships he's carried and helped to lift the heavy load upon our souls. But we concluded him to be struck down and cursed by God; thus the reason for his frustrations in life.
But his heart was pierced and emptied because of our rebellion. He was crushed to the point of total prostration for the sake of being punished for our guilt. This correction that secured our peace with God was laid against him; that by his being bruised, we were made completely whole.
These verses as taken together, considering the whole of Jesus's life and not only the 3 days and 3 nights of enduring wrath; give us more of a complete picture of what he actually did. The Scripture says he "learned obedience" and "Being found in fashion as a man, he humbled himself and became obedient unto death, even the death of the cross." Philippians 2:8
This learning obedience started from the first moment he was consciously aware of his own internal desire to be obedient.
Isaiah 52
13 Behold, my servant shall deal prudently, he shall be exalted and extolled, and be very high.
14 As many were astonished at thee; his visage was so marred more than any man, and his form more than the sons of men:
15 So shall he sprinkle many nations; the kings shall shut their mouths at him: for that which had not been told them shall they see; and that which they had not heard shall they consider.
Verse 13
Behold, on account of his wise understanding; my Servant shall rise up, being carried on high to exceeding exaltation.
Verse 14
Just as many were made desolate on account of; therefore was he ritually corrupted more than any man, of his inclination toward majestic ornamentation more than the sons of men.
Verse 15
Therefore he shall cause to leap: Nations, as locusts more numerous (than Israel) against / upon / on the ground of, to draw together closed the mouths of kings, for what not had been taken into consideration by them; they shall be forced to see to. And also who they would not listen to; they will consider diligently.
Behold, on account of his wisdom; my Servant shall rise, being carried on high in exceeding exaltation.
Just as many are made desolate on account of him; his likeness was intentionally distorted more than any man and the nature of his Kingship more than the sons of men.
Therefore he shall send nations as locusts to cover the land of Judah and shut the mouths of kings, for he they did not consider, now they are forced to recognize. Also, he who they would not hearken to; they will be forced to consider diligently.
So there's my additional "2 cents".