This mitzvah of loving others is primarily done in one’s heart: never rejoice at another fellow’s failing, Heaven forbid; rather, share his happiness when it is good for him and share his hardship when he is suffering until it brings you to the point that you pray for him.
The way to acquire this love is by taking to heart that which our Sages said, that when the wicked suffer, the Holy One, so-to-speak, suffers along with them (see Chagiga 15b) from which we may infer the opposite as well: When a person is at ease, Hashem is also “at ease.” And, if so, one who loves Hashem should be happy along with Him and grieve along with Him. More, when someone is in a tranquil state, and has wealth and possessions, it is not difficult for him to do many mitzvos and good deeds — all of which is pleasing to Hashem. But when a person is experiencing difficulty, he loses vigor and tends to fall short in his service of Hashem even, sometimes, going against the will of his Creator. Therefore, one should rejoice at his fellow’s success, because that success will lead to an increase of mitzvos and good deeds. One would feel the opposite when his fellow is suffering.
Included in this is that one should be extremely happy when he sees other Jews doing the will of Hashem and feel pain by those who commit sins. Even when someone knows that he is falling short in his own spiritual responsibilities, he does not want his friend to be like him, for “the plight of many is the consolation of fools.”
Another reason to rejoice over a friend’s material success is that it will enable him to keep many mitzvos and do many good deeds, and as a result of that everybody benefits, because mitzvos and good deeds tip the scales of the whole world to the side of merit. When it is a good day, it is good for you too.