A secondary character in a story that the author uses to highlight the protagonist personality or characteristics is called character foil.
In a story, a foil is a character who contrasts with another character, generally the protagonist, to highlight qualities of the other character. Sometimes, a subplot can be used as a foil to the main plot.
A foil generally either differs dramatically or is extremely similar but with a fundamental difference setting them apart.