Since Arjuna was a warrior, Krishna advised him to perform his duty without self-interest. If a soldier does not want to engage in war but wants to be a mendicant instead, as proposed by Arjuna, then he should not join the army. It is paradoxical to join the army and then refuse to fight when the need arises. The army has the responsibility to protect a nation from its enemies. By engaging in warfare when necessary, the army grants a peaceful life to the civilians. The duty of a policeman, a soldier or a king, is to be impartial for the sake of the nation, even if they have to stand up against their own teachers or relatives.
Krishna is not propagating violence. Rather, he is imploring Arjuna to vanquish the enemies, i.e. his cousins, who plotted to kill him and his brother surreptitiously by poisoning their food, setting fire to their residence and other such hideous means. A soldier protects citizens and prevents violence.
It takes a lot of beating before you can come to your senses. And that is the grace of God that he will keep on beating you and smashing you until you understand. He will not leave you until you understand – whether it takes one life, two lives, three lives, it doesn’t matter. That is His compassion.