How many times in past few weeks people have asked you that? Especially when you have been having a bad day or a week or a month or a year of maybe a bad life? Some people(mostly women) have the gift of detecting negative emotions in others at a very early stage, some don't. But irrespective of that when someone asks you if you are OK, what would be the right answer?
I don't think truth is the right answer here. People don't want to hear your sob stories, they don't want to get into the muck of your life. They have their own muck to deal with. If at all someone is keen on knowing the reason behind your unpleasant demeanor then I guess mostly it is for gossip reasons.