Janitors realize that the people they work around have no control over what they earn in the vast majority of cases. What people do have control over is their behaviour towards janitors, whether their direct interactions are respectful and whether they make the job of those tasked to cleaning up easier or more difficult.
Being nice also makes a difference in the sense that being nice makes a difference when you are working with your colleagues. Having healthy attitudes towards each other reduces stress and remove roadblocks to getting work done.
You can control it. Give him part of your salary, instead of throwing him useless smiles and acknowledgment.
Saying you can't control it is a lie you tell yourself to feel better. You obviously can control part of it. We all can. But why don't I give him my salary? Because I care more about my salary then his suffering. Same with you.
Being nice also makes a difference in the sense that being nice makes a difference when you are working with your colleagues. Having healthy attitudes towards each other reduces stress and remove roadblocks to getting work done.