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.