The expression "pay it forward" is used to describe the concept of asking that a good turn be repaid by having it done to others instead. In contract law, typically there are two parties but there is the concept of third party beneficiaries. Pay it forward merely applies this contract law concept so that third party beneficiary be a stranger to the creditor. More specifically, the creditor offers the debtor the option of "paying" the debt forward by lending it to a third person instead of paying it back to the original creditor. Debt and payments can be monetary or by good deeds. In sociology, this concept is called "generalized reciprocity" or "generalized exchange". A related transaction, which starts with a gift instead of a loan, is alternative giving.
The concept was used as a key plot element in the denouement of a New Comedy play by Menander, Dyskolos (a title which can be translated as "The Grouch"). Dyskolos was a prizewinning play in ancient Athens in 317 BC; as the text of the play then disappeared and was not re-published until 1957, the concept had to be rediscovered.
The concept was rediscovered and described by Benjamin Franklin, in a letter to Benjamin Webb dated April 25, 1784: I do not pretend to give such a Sum; I only lend it to you. When you [...] meet with another honest Man in similar Distress, you must pay me by lending this Sum to him; enjoining him to discharge the Debt by a like operation, when he shall be able, and shall meet with another opportunity. I hope it may thus go thro' many hands, before it meets with a Knave that will stop its Progress. This is a trick of mine for doing a deal of good with a little money.