I don't know about the money they spent, but I believe thinking about it as a free product isn't the right approach. It delivers data & insights and gives them (some) control over the platform that powers their core business, much like Android gives them (some) control over the mobile platform. That's probably well worth whatever they spend on it.
With Firefox and Chrome (and Chrome forks that aren't independently developed, but mostly kept close to the source with some added functionality), they're offering all the options on the market (except Safari, but it's not an option on the global market, only on Apple), if you want a Browser, you'll use something Google-controlled, one way or another.
Yoric wasn't referring to actual money that traded hands; the 2 billion USD figure included the estimated value of being featured on google.com.
And I'm certain that Google determined that whatever they paid for it (in cash or opportunity cost or whatever) was worthwhile to them! (And today, it very much looks like they were right.)
With Firefox and Chrome (and Chrome forks that aren't independently developed, but mostly kept close to the source with some added functionality), they're offering all the options on the market (except Safari, but it's not an option on the global market, only on Apple), if you want a Browser, you'll use something Google-controlled, one way or another.