I understand that "flagging" means "to get weaker," or "exhuasted and slowed," but I don't understand why. I presume it comes from a metaphor of some kind, but I cannot identify its origin. Can anyone help?
The Online Etymology Dictionary has it that the meaning you cite derives from old Norse:
is from Old Norse flaka "to flicker, flutter, hang losse," perhaps imitative of something flapping lazily in the wind. Sense of "go limp, droop, become languid" is first recorded 1610s.
Somewhat speculative, I'm not immediatley able to find or offer anything more definitive.
According to the OED, the verb to flag, comes from Old French flaquir - to become flaccid. It doesn't seem to make an appearance in English until the sixteenth century.
Etymology: ? < flag adj.; compare Old French flaquir to become flaccid. But probably there is a mixture with an onomatopoeic formation, expressing the same notion as flap, flack, but implying less energetic movement.
1540 [implied in: R. Jonas tr. E. Roesslin Byrth of Mankynde i. f. lviv That her brestes..be neyther to great, softe, hangynge, and flaggynge.
If you look at the OED, the first uses of the word flag meaning to grow weaker were applied to birds.
3 a. intransitive. Of wings: To move feebly or ineffectually in attempting to fly. Of a bird: To move its wings feebly (in early use also transitive with wings as object); to fly unsteadily or near the ground. Obsolete.
1590 Spenser Faerie Queene My Muse, whose fethers..Doe yet but flagg, and lowly learne to fly.
1605 B. Jonson Sejanus Croaking Ravens Flag'd up and downe.
This was a natural extension of the earlier definition:
1 a. intransitive. To hang down; to flap about loosely.
The word was later applied to other kinds of weakening, probably figuratively at first:
1665 R. Boyle Occas. Refl. Too commonly our Resolutions flagg with our Joys.