"Goldman Sachs buys a home loan at 50 percent off. It then modifies the mortgage for the borrower to perhaps 60 percent of face value. The modification gets referred to the overseer of the mortgage settlement, proving that Goldman did lower the cost for the homeowner. And as homeowners begin to make modified payments, the bank can resell the now-performing loans, or just take in the revenue stream. If this works, Goldman makes at least a 10 percent profit on the deal, while satisfying the consumer relief terms of the settlement."[1]
The above glosses over the notion of it working by saying "if it works," but for the most part, it does.
[1] https://finance.yahoo.com/news/goldman-sachs-wins-lose-mortg...
Good reference, too:
https://www.nytimes.com/2017/03/17/business/dealbook/mortgag...