Morality of good and bad are entirely subjective and opinionated. That's what you'll need to work on reflecting outwards. Regardless of where you are in life, undesirable situations - involving "bad" people will arise and the array of actions which can be taken are circumstantial, and the consequences even more circumstantial.
To take your example, wherein another individual begins to make fun of the child, and decompile the causality of it, we can immediately see that the "bad" in this situation is dependant on how your child perceives and understands what the other individual is saying. Your child is faced with 2 (main) scenarios, one where they perceive it to be a positive , humoured conversation and one where they perceive it to be negative.
In the first scenario they could embrace it with laughter and counter 'humour', be intellectually witty in response or positively contest it.
In the second scenario, they could be stoic and reserved and let them do it, confront them with agitation or aggression in mind or simply ignore it and report it.
As social creatures it's entirely normal for humans to verbally contend with one another - admittedly it's gotten a little lost in translation within the newer generations - and the main principle of education for children should be in confidence, acceptance and respect.
It's entirely possible for your child to positively react to ill-intentions with witty humour that isn't negative or a form of attack, it's in this confidence that ill-intention and verbal contests are won and respect is given.
An example from modern society , mainly focusing around appearance, would be the mocking of a haircut.
An individual might remark "Did your mum cut your hair?" This is a verbal contest of wealth and style.
Your child could respond with "No, I wasn't sure what I wanted and it didn't turn out as good as it could have - I like your hair though, what did you ask for?"
The problem , especially with children, is that their sense of morality isn't developed to include this kind of contention - personal attacks on image and the usual things are a result of modern media classification and vast diversity.
To edge around this , you introduce morally clear lines - by complimenting the individual your child is offering a positivity and kindness that, if attacked as a result of being offered, will instil a sense of bad morality , it is therefore a lot more likely that the person will come to find a sense of respect and mutual understanding with your child. (it's important to note that most children experience the same situations and it is those who are more confident to push through them.)