It justified violence as the last resort which can be taken literally in the story or as a metaphor for when someone hits rock bottom in their life. War is one of the worst things to be a part of and personal demons can feel like a battle. I actually praise it for choosing a topic that shouldn't exist in an ideal world but it knows that that's not reality and war is sometimes required (Vedic scripts would say we're in the age of "Kali Yuga", believing time is cyclical, the utopian phase of world peace simply doesn't exist).

The Bhagavad Gita is a subset of the Mahabarata epic, albeit the most famous one, so the preceding story was that peaceful negotiations were not possible even though that was the route preferred. The idea is that if two sides are willing to negotiate peacefully, that is the option that should be taken. But if one side insists on war, action (karma) and inaction (akarma) are two sides of the same coin - inaction is not avoiding doing something, it is a form of action ("He who seeth inaction in action and action in inaction, he is wise among men; he is a Yogi and performer of all actions"). In fact, Ghandi actually wrote a letter to Hitler initially asking him "peacefully" to stop WW2. This was followed up with a less peaceful letter [0]. It would seem he was happy for violent war against Nazis because they were evil and it was against injustice. (Naturally, this leads to discussions on what one would consider evil but the idea is not to be the first to attack and provoke). The ending of the epic is wasteland of emptiness caused by the war - both as a symbol of the waste of war but also as an idea that everything and nothing exists at all times; whether you chose action or inaction is on you, time destroys all regardless.

Ghandi (and I guess Oppenheimer [1] to a degree but not sure) seemed to take the concept of Dharma (duty) to strengthen his resolve and he accepted what he considered his Dharma to keep going through the difficult times. The other aspect is that Arjuna did not choose the war but his previous actions (karma) have led him to be where he is. Just like what is said nowadays about how your past makes you who you are today. Sometimes the battle is unavoidable given past actions.

Sorry, probably too long a response :D but I genuinely had the same thought as you when I first started reading about it but then did some further reading. There's so much to dissect, from all sides, which is why I think it's one of the greatest philosophical works written.

Interestingly enough, if you watch the first Matrix with the Bhagavad Gita in mind, you'll notice a lot of parallels in the hidden meaning of the Gita and Hindu philosophy about what we consider 'real' and how life is an illusory. So much so that the Matrix Revolutions soundtrack during the end fight is a famous Sanskrit mantra from the Upanishads

asato ma sad gamaya

tamaso ma jyotir gamaya

mrtyor mamrtam gamaya

(From delusion lead me to truth

From darkness lead me to light

From death lead me to immortality)
[2]

Imagine Neo is Arjun.... there is no spoon ;)

[0] https://www.indiatoday.in/news-analysis/story/when-mahatma-g...

[1] https://www.youtube.com/watch?v=lb13ynu3Iac

[2] https://www.youtube.com/watch?v=A67OhOUoUsc