The article is about Fannae Mae and Freddie Mac which buys loans from lenders and turns them into mortgage backed securities.
The lender is not in the business of issuing a loan and then collecting the cash for 30 years. The lender is in the business of issuing the loan and selling it to Fannae Mae.
I don't know what determines the interest rate in this scenario, but Fannae Mae needs to account for mortgage default risk when they operate the program. It is not run as a charity and the possibility of mortgage default means it is not risk free to Fannae Mae.
There are government guaranteed loans not covered by this article like FHA and VA loans which have mortgage insurance, but I don't think they are cost free to the lender if the loan defaults. I believe the lender needs to comply with regulatory requirements and has costs related to making an insurance claim and proving eligibility for an insurance claim when they get compensated.
"The FHA reimburses only about two thirds of foreclosure expenses, interest is not reimbursed for the first two missed payments, and interest is reimbursed at the HUD debenture rate for subsequent missed payments."
More info is at this article:
https://www.google.com/url?sa=t&source=web&rct=j&url=https:/...