It appears to be a custom that predates establishment of the Christian religion, but you can find a scriptural example in 1 Corinthians 11:23-25(KJV)
That the Lord Jesus the same night in which he was betrayed took
bread: And when he had given thanks, he brake it, and said, Take,
eat: this is my body, which is broken for you: this do in remembrance
of me. After the same manner also he took the cup, when he had
supped, saying, This cup is the new testament in my blood: this do ye,
as oft as ye drink it, in remembrance of me.
A more modern rendering: (NAB)
23 * For I received from the Lord what I also handed on to you, that
the Lord Jesus, on the night he was handed over, took bread,
24 and, after he had given thanks, broke it and said, “This is my body that is for you. Do this in remembrance of me.”
25 In the same way also the cup, after supper, saying, “This cup is the new covenant in my blood. Do this, as often as you drink it, in remembrance of me.”
26 For as often as you eat this bread and drink the cup, you proclaim the death of the Lord until he comes.
In current Catholic practice, for example, the Grace said before a meal is a form of being thankful (albeit in somewhat stilted language):
Bless us oh Lord, and these thy gifts, which we are about to receive,
through thy bounty
There is a deeper tradition involved in the Greek and Roman churches where the meal (the Eucharistic meal, the Lord's Supper) is by its name a communal prayer, and a communal act of thanksgiving. Prayers of thanksgiving well predate Christian practice, in the Psalms. As instructed in the current Catholic teaching ...
2588 The Psalter's many forms of prayer take shape both in the liturgy
of the Temple and in the human heart. Whether hymns or prayers of
lamentation or thanksgiving, whether individual or communal, whether
royal chants, songs of pilgrimage or wisdom meditations, the Psalms
are a mirror of God's marvelous deeds in the history of his people, as
well as reflections of the human experiences of the Psalmist.
There is also the admonition from the Apostle Paul: Pray constantly.
1 Thessalonians 5: 16-18.
16 Rejoice always. 17 Pray without ceasing. 18 In all
circumstances give thanks, for this is the will of God for you in
An allusion to giving thanks before a meal also comes from Romans 14:6
Whoever observes the day, observes it for the Lord. Also whoever eats,
eats for the Lord, since he gives thanks to God; while whoever
abstains, abstains for the Lord and gives thanks to God.
Matthew 15:34-36 is another example Jesus demonstrating the giving of thanks before eating
34 Jesus said to them, “How many loaves do you have?” “Seven,” they
replied, “and a few fish.” 35 He ordered the crowd to sit down on
the ground. 36 Then he took the seven loaves and the fish, gave
thanks, broke the loaves, and gave them to the disciples, who in turn
gave them to the crowds*.
While that doesn't confirm the origin of this custom, @toothbrush points to a Jewish thanksgiving custom/prayer thought to be the thanksgiving that Jesus used:
(@Toothbrush)These passages reference the Jewish blessing (There are
also other blessings pronounced for other foods.)
for bread (ברוך אתה יהוה>אלוהינו מלך העולם המוציא לחם מן הארץ; Blessed are You, LORD our God, King of the universe, Who brings forth bread from the earth)
for wine (ברוך אתה יהוה אלוהינו מלך העולם בורא פרי הגפן — Blessed are You, LORD our God, King of the universe, Who creates the fruit
of the vine).