I'd say just assumptions based on average asteroid field density/size as well as average Star Destroyer stats, etc. I'm not really sure why he'd know, but it might be useful to provide better context when translating or negotiating. Maybe they just wanted to support the fact that droids obviously can know lots of stuff, but they might never be able to determine the right situation to use that knowledge on their own. To be honest, I don't remember that scene in detail. Did C-3PO come up with these on his own or did he just translate R2-D2? In latter case it would most likely be useful as part of his role supporting fighter craft and stuff like that.
Things like that appear in other fiction having self-aware/intelligent AIs too, e.g. Knight Rider. So, even considering there is lots of background stuff behind many things related to Star Wars and I don't have any quote or source for this, I'd still say Lucas just found it neat to have that little discussion.