The secondary market is a bundle of loans. They package outstanding credit deals with low rates, including 0%, with subprime and lower credit with high interest rates. It is a package deal. The high credit zero percent deals maintain positive cash flow for the secondary lenders if they end up having to collect on the bad credit deals. This is required by the regulators. The secondary lenders cannot absorb only high risk deals. They have to blend them. Even primary lenders keep a subset of these loans on the books. It is about the whole portfolio. This is about the forest, not the trees. The inverse can happen, too. If a lender has too many high credit low risk deals, they may decline someone who has great credit. They are just keeping their books balanced.
Think of it this way, instead of 1, 0% $35k loan and 10, 10% $35k loans, the bank has 11 loans with $385k at something like 9%. Multiply this out by thousands. If you were lending on one loan, sure you would not lend at 0% to make money....though to say they only make money on interest is also wrong. Banks don't look at it as one loan. The goal is to be one of the small percentage they use to balance their books.