score:59
I think it has always been done, e.g., 3,000 years ago Greeks justified a war by a kidnapping allegation.
Justification of war is important for one's own troop and population morale, so the theoretical framework has been around for millennia.
Paraphrasing @SPavel, "your people are unlikely to risk their lives just because you are bored, or greedy, or horny".
Note that this does not mean that the justification has to be fake. If your group (tribe, city, state, nation, empire) is starving, waging a war for resources is likely to sound reasonable to your people.
The bottom line is that the war pretext exists first and foremost for internal consumption. (Here internal may include allies).
A secondary reason is actually getting more and more important with the development of civilization and diplomacy: avoid war in the future. A party which, first, clearly states the reasons for war, and, second, sticks to them (i.e., goes to war if and only if certain conditions are satisfied), may be less likely to find itself faced with war (depending on how reasonable the conditions sound to the neighbors and how reasonable those neighbors are themselves).
Regarding this secondary reason and avoiding war in the future in general, please see the Nobel lecture aptly named War and Peace by Robert Aumann - a genius game theorist.