This is addressed in the Gita in several places. Gita 13.27-28 says (Swami Gambhirananda translator):
He sees who sees the supreme Lord as existing equally in all beings, and as the Imperishable among the perishable.
Since by seeing equally God who is present alike everywhere he does not injure the Self by the Self, therefore he attains the supreme Goal.
And in Gita 6.9:
He excels who has sameness of view with regard to a benefactor, a friend, a foe, a neutral, an arbiter, the hateful, a relative, good people and even sinners.
Swami Vivekananda comments on verse 13.28 above in his Complete Works V3, p 425 (Available here under the heading 'Lectures from Colombo to Almora', sub-heading 'The Vedanta' - http://www.advaitaashrama.org/cw/content.php):
In the second place, Advaita and Advaita alone explains morality. Every religion preaches that the essence of all morality is to do good to others. And why? Be unselfish. And why should I? Some God has said it? He is not for me. Some texts have declared it? Let them; that is nothing to me; let them all tell it. And if they do, what is it to me? Each one for himself, and somebody take the hindermost — that is all the morality in the world, at least with many. What is the reason that I should be moral? You cannot explain it except when you come to know the truth as given in the Gita: "He who sees everyone in himself, and himself in everyone, thus seeing the same God living in all, he, the sage, no more kills the Self by the self." Know through Advaita that whomsoever you hurt, you hurt yourself; they are all you. Whether you know it or not, through all hands you work, through all feet you move, you are the king enjoying in the palace, you are the beggar leading that miserable existence in the street; you are in the ignorant as well as in the learned, you are in the man who is weak, and you are in the strong; know this and be sympathetic. And that is why we must not hurt others. That is why I do not even care whether I have to starve, because there will be millions of mouths eating at the same time, and they are all mine. Therefore I should not care what becomes of me and mine, for the whole universe is mine, I am enjoying all the bliss at the same time; and who can kill me or the universe? Herein is morality. Here, in Advaita alone, is morality explained. The others teach it but cannot give you its reason. Then, so far about explanation.