I think this particular topic is just another learned social reflex, kind of like saying hello to someone you pass by, but in situations where people are spending slightly more time together than passing one another, such as in an elevator. There is a set of socially acceptable things to talk about that are supposed to be able to work with just about anyone, but particularly, with strangers or acquaintances, and the weather is one of the topics in the set. t can also be a way to start a real conversation with someone you want to talk to, because just getting to the point and saying what you want to say may be considered rude or weird.