“Trope: ‘Kick the Dog’”, (; backlinks):
When a character does something evil, cruel or very mean for no apparent gain, because the author wants to demonstrate that he’s not a nice guy and shift audience sympathy away from him.
Why this trope works could be expressed in the words of William Cowper: “I would not enter on my list of friends (though graced with polished manners and fine sense, yet wanting sensibility) the man who needlessly sets foot upon a worm.” In other words, a cruel act, no matter how trivial, establishes someone as a cruel person. Conversely, the creator may show a character being kind for no apparent gain, to demonstrate that the character is a nice person and someone the audience is meant to cheer for. Both devices are used to help the audience become emotionally invested in the story.
What separates this trope from a character’s other evil or cruel acts is that this bit of evil is gratuitous. It doesn’t get the character anything or even advance the plot. The sole reason for this story beat existing is to place one or more characters squarely on the wrong side of the Rule of Empathy.