It's not only some demanding command to modify your mood, it can be a good natured suggestion to try and keep your chin up. The person who said it to me most was my mother.
Wow. If you're curious as to why some view it as a condescending thing to say to a colleague you really could start there.
edit: I'm surprised by your reply... only because it seems incongruous with the statement I replied to. interesting.
Just because people were well-intentioned didn't make it any less infuriating. I've gotten it in the "cheer up" sense and the "be more presentable" sense and the "comply with norms" sense. Not a huge difference in how it feels, non family ones are a bit easier though.
No matter how ill advised or inappropriate you find it, I don't think you should assume intent.
At least, where I'm from this is true. Maybe it's a societal norm that varies by culture and region.
I'm not dealing with clinical depression but I can see what you mean. If I'm upset enough about something that it is visible, the last thing I want is someone telling me to "cheer up."
I guess I'm fortunate never to have worked with the kind of people (commissioned sales people? politicians? child molesters? I mean, I can't even imagine) who would notice I'm upset and tell me to "smile."