The stars in the upper left corner of their avatar indicates a Mercenary’s current Class. There are 6 different Classes.
To improve your Mercenary's Class you must first get your Mercenary to the highest Level their current Class allows. You should then retire Mercenaries of the same Class as the chosen Mercenary.
The number of Mercenaries you retire must be equal to the current Class of your Mercenary. For example, a Class 2 Mercenary must have two Class 2 Mercenaries retired for it to reach Class 3.
After its Class is improved, your Mercenary’s Level is reset. You must get them up to the highest Level available again to reach the next Class.