They do need to make money in some way, ever since Google didn't renew their contract with Mozilla (which iirc was 98% of their revenue back in the day) after Chrome started taking off.
Mozilla actually moved to Yahoo not because Google refused to renew their contract, but because Yahoo was flush with cash and desperate to gain any foothold at all in search engine share (which they did, briefly; a friend of mine at Google had the job of getting Firefox users to switch their default search back to Google). Yahoo just offered better terms than Google at the time.