Faust is the protagonist of a classic German legend in which a medieval scholar makes a pact with the Devil.
There are many versions of the legend. Sam appears to be reading a synopsis of the play The Tragical History of Doctor Faustus by Christopher Marlow, a contemporary of Shakespeare's. In the Marlow version, while Dr Faustus tries to repent, the Devil claims his soul (although the ending is slightly ambiguous).
The other well-known version is the play by Goethe. In this play, the Devil (Mephistopheles) makes a bet with God that he can distract Faust from his quest for knowledge.
At a moment when Faust is frustrated in his studies, the devil makes an offer - he will do everything that Faust wants while he is here on earth, and in exchange Faust will serve the devil in hell.The moment Faust attains pure happiness, the Devil will take his soul. Faust is pleased with the deal, as he believes the moment will never come.
In contrast to the conclusion in Marlowe's version, but when the devil tries to grab Faust's soul when he dies, God intervenes and saves Faust in recognition of his struggle.