I'm not sure it's population density or at least not that alone. There are parts of the West with comparably high densities, especially in large cities, and covering your face is generally frowned upon.
I suspect that the cultural focus on cleanliness has a lot to do with it, but given that it's Hacker News there may be someone with a more exact idea of the origin.
You wear one if you're sick. So that you don't get other people sick basically.
Contrast with my experience in Sydney, where catching the bus during flu season is bloody hazardous. Being coughed and sneezed on gets old quickly, so I totally understand the surgical mask thing; it's a basic courtesy.
I suspect that the cultural focus on cleanliness has a lot to do with it, but given that it's Hacker News there may be someone with a more exact idea of the origin.