People tend to want to call it jelaousy, but I don't think that is the case most of the time.
Some people are like that unfortunitely, I think it's common to make jokes about working at McDonalds, fetching fries for people without actually considering that there is a human behind the register.
It is easy to dehumanize people, unfortunitely. And many people just lack manners and common sense.
Personally I have about zero respect for a person who makes negative remarks on people because of their job. If a person has a job, people should be grateful.
As for you getting sad about it, it's really terrible, I just want you to know that they are clearly wrong in what they are doing.
Just imagine yourself in their shoes, would you ever, regardless of where you were in life go into a restaurant and tell one of the HUMANBEINGS working there that they had no life? Wouldn't you feel like a real loser if you did such a thing? Apply it to the person doing it.
It is rude, obnoxious and silly.
Just tell them something like "I am paying my taxes, contributing to society. You are either just like me or unlike me, living off the charities of others. In either case, you are in no place to judge. Please behave like a decent citizen and show me the same respect I am showing you."
Or something like that.
I guess it is hard to argue, either they will realise their mistake and be ashamed, or their head is so thick and full of poop that they will try to insult you, either way, they are wrong.