The answer to this begins in the Prologue where God says he is convinced Faust will always choose right regardless of Mephistopheles temptations. In fact, it is God who turns Mephistopheles' attention to Faust and lays the conditions for his wager with Mephistopheles (the first of two wagers in Faust):
God: Do you know, Faust?
Mephistopheles: The Doctor?
God: My servant, first! [...]
Though he’s still confused at how to serve me,
Mephistopheles: What do you wager?
Faust's transcendence begins immediately after losing Euphorion and Helen. Faust is left alone. Helen's garments evaporate to mist. On that mist, Faust is flying on a cloud over land and sea. When atop the mountains where the cloud deposits him, he turns his thoughts to helping mankind, to doing "what Men need," Faust refocuses Mephistopheles on a world-oriented vision: "That’s my desire, so be brave and promote it!"
Phorkyas (To Faust.)
[Keep the] Noble gift for yourself, and soar on high:
It will carry you quickly from the lowest
(Helen’s garments dissolve in mist, surround Faust, lift him into the air, and drift away with him.)
The old couple, Baucis and Philemon, allows a demonstration of how Faust is now transcended and separated from Mephistopheles, despite all that has gone before. The demonstration gives substance to Faust's reproach of Mephistopheles for destroying the cottage and the couple and to his yearning to let go of magic as expressed in his encounter with Care: "Take care: of magic spells show not a trace."
The couple's purpose is to demonstrate Faust's transcended state; to confirm his rejection of magic; to affirm his reconnection to living, thus rejecting the quest for ultimate knowledge; and to demonstrate Faust's final separation from and rejection of Mephistopheles.
Faust: If I could banish Sorcery from my track,
Unlearn the magic-spells that draw me back, 11405
And stand before you, Nature, as mere Man,
Their presence make Goethe's thematic point of redemption plausible. God wins the wager. Faust rejects evil and embraces good. Thus Gretchen's prayers for Faust may be granted and Faust snatched from the hands of demons even on the other side of death:
God: A good man, in his darkest yearning,
Is still aware of virtue’s ways.