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).
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.