According to the Cambridge Dictionary, to rub it in is to make someone feel worse about something the person already feels embarrassed about:
I know I shouldn’t have paid that much for the poster – don’t rub it in, OK?
According to the Collins English Dictionary, to rub it in is to keep on mentioning to someone his or her failure or mistake, often with some malice.
In formal speech, the equivalent could be “to humiliate someone over something.”
We should not humiliate our friends over the stupid mistakes they have made.