Let's take a simple example. I loan you $10k to buy a truck. Not too long after you get it, a meteorite hits you and your truck. Disintegrating both completely. You have no money in the bank, insurance, or anything for me to get my $10k back.
The truck (or student loans) was still paid for. I thought I'd get my money back, but I didn't and that is a risk in loaning money. I can write that off as a loss in my taxes, and recuperate some of the losses, but definitely not all.
So in our student loan case somebody still has to pay off that debt. Either it is by a massive loss to the companies that loaned the money (let's ignore the possibility of them being in the green) or the federal government purchases the loans and writes them off. And if the loan companies are forced to write them off then that is written off as an expense and can greatly change how their taxes are calculated (see Trump). Which the "pays for" is that purchase or tax deduction/rebate. And now the entire tax paying population pays for (which tbh I'm personally okay with). But it still gets paid by somebody. Somebody "loses" (maybe not in the long run, but in our short game).