Because LSB notes that "Stanza 2 may be reserved for occasions when Luke 10:38-42 is read," I'm also including those verses.
Luke 10:38-42: "38 Now as they went on their way, Jesus entered a village. And a woman named Martha welcomed him into her house. 39 And she had a sister called Mary, who say at the Lord's feet and listened to his teaching. 40 But Martha was distracted with much serving. And she went up to him and said, 'Lord, do you not care that my sister has left me to serve alone? Tell her then to help me.' 41 But the LORD answered her, 'Martha, Martha, you are anxious and troubled about many things, 42 but one thing is necessary. Mary has chosen the good portion, which will not be taken away from her.'"
Philippians 3:7-8: "7 But whatever gain I had, I counted as loss for the sake of Christ. 8 Indeed, I count everything as loss because of the surpassing worth of knowing Christ Jesus my Lord. For his sake I have suffered the loss of all things and count them as rubbish, in order that I may gain Christ"
Hebrews 9:14: "how much more will the blood of Christ, who through the eternal Spirit offered himself without blemish to God, purify our conscience from dead works to serve the living God."
John 13:15-17: "15 'For I have given you an example, that you also should do just as I have done to you. 16 Truly, truly, I say to you, a servant is not greater than his master, nor is a messenger greater than the one who sent him. 17 If you know these things, blessed are you if you do them.'"
+++
The text is public domain:
One thing's needful; Lord, this treasure
Teach me highly to regard.
All else, though it first give pleasure,
Is a yoke that pressed hard!
Beneath it the heart is still fretting and striving,
No true, lasting happiness ever deriving.
This one thing is needful; all others are vain -
I count all but loss that I Christ may obtain!
How were Mary's thoughts devoted
Her eternal joy to find
As intent each word she noted,
At her Savior's feet reclined!
How kindled her heart, how devout was its feeling,
While hearing the lessons that Christ was revealing!
All earthly concerns she forgot for her Lord
And found her contentment in hearing His Word.
Wisdom's highest, noblest treasure,
Jesus, is revealed in You.
Let me find in Your my pleasure,
And my wayward will subdue,
Humility there and simplicity reigning,
In paths of true wisdom my steps ever training.
If I learn from Jesus this knowledge divine,
The blessing of heavenly wisdom is mine.
Nothing have I, Christ, to offer,
You alone, my highest good.
Nothing have I, Lord, to proffer
But Your crimson-colored blood.
Your death on the cross has death wholly defeated
And thereby my righteousness fully completed;
Salvation's white raiments I there did obtain,
And in them in glory with You I shall reign.
Therefore You alone, my Savior,
Shall be all in all to me;
Search my heart and my behavior,
Root out all hypocrisy.
Through all my life's pilgrimage, guard and uphold me,
In loving forgiveness, O Jesus, enfold me.
This one thing is needful; all others are vain -
I count all but loss that I Christ may obtain!
+++
The text from Luke 10 is the primary source. The entirety of the second verse is drawn from it. The clause "'one thing is necessary'" from verse 42 appears near the end of the hymn's first and fifth verses ("one thing's needful"), combined with the text from Philippians 3 ("I count all but loss that I Christ may obtain!").
Hebrews 9:14 seems to appear in the fourth verse, although the hymn's phrase "Salvation's white raiments" bears more resemblance to Revelation 7:13-14: "13 Then one of the elders addressed me, saying, 'Who are these, clothed in white robes, and from where have they come?' 14 I said to him, 'Sir, you know.' And he said to me, 'These are the ones coming out of the great tribulation. They have washed their robes and made them white in the blood of the Lamb."
The "example" from John 13 is rendered as "In paths of true wisdom my steps ever training" in the hymn's third verse, and "'If you know these things, blessed are you if you do them'" is paraphrased as "If I learn from Jesus this knowledge divine, / The blessing of heavenly wisdom is mine."