This isn’t a vague philosophical question whose answer is inevitably “End war now.” I, along with every soldier I’ve ever met, would love to live in a world without war. Unfortunately we don’t. The question of why we have a military is actually a very important real-world question which the Pentagon itself asks and then answers every four years in its Quadrennial Defense Review.
In order to figure out how many of those tanks, sailors, nuclear war heads, fighters etc., we have to answer one very simple and complex question: What do we want the military to do?
The answer at first seems obvious. Nations have militaries in order to protect themselves, right? That’s part of it, but what is it protecting us from? In some cases this is easy to determine. Israel, for example, needs protecting from neighboring states which would like it cease existing. India wants its military to protect it from its neighbors to the north, Pakistan and China, as well as rebellious groups which pop-up from time to time.
Defining protection can be quite complex and India is a perfect example of this. India has at different times fought with both Pakistan and over control of some or all of India’s northern province of Kashmir, which borders the other two nations. What’s odd about that is there is little there to fight over. Kashmir consists mostly of a part of the Himalayan Mountains. It is a beautiful, inhospitable area. It’s barely populated and so far few, if any, valuable resources have been discovered there. Not only is there little if any reason to fight over Kashmir, it is also a terrible place for military operations. It is distant from everywhere, making resupply difficult even for the nations bordering it. With the possible exceptions of the South Pole and Siberia in mid-winter, it is likely the most difficult place on the planet to conduct a war. Not that has stopped any of the three nations from trying. To this day, the armies of India and Pakistan occasionally fire artillery shells at each other just to see if anyone is paying attention.
You get the feeling that the nations themselves know this. Consider the war between India and China in 1962. It lasted about a month and resulted in about 2,000 deaths. The cause both sides claimed to be fighting for was territory, a resource both nations have in abundance.
In which case, why did they fight? At the time of the war both nations were relatively young as independent, unified political entities. India had become a free nation in 1947 when the British, who had ruled India as a colony for more than a century, handed control of the government to the indigenous people. China had become a nation united under a government of its own people at roughly the same time, after the Communists kicked out the Japanese, the Nationalists and the various colonial powers which had controlled the nation for the past century. In 1962, China was perceived as having an expansionist foreign policy because it had conquered Tibet a few years earlier. Just before the conflict the Indian government set up some border posts on parts of the land no one really wanted but which the Chinese considered to be on their side of the border. So China attacked in order to push them back to the correct part of the land no one really wanted. In other words, two young nations/governments wanted to prove that they couldn’t just be pushed around and so 2,000 people died., 
So we can see from this example that militaries are not just used for protection.
Certainly directly protecting the borders of the nation isn’t why the United States has such an enormous military. The U.S. is ideally situated defensively. In the east and west two oceans separate it from the rest of the world. Its two other borders are with Canada and Mexico, neither one of which have ever posed even a nominal military threat to the nation. It has been 200 years since a foreign power directly invaded the U.S. The only real direct threat to the nation’s existence was 150 years ago and that came from other Americans. It is this splendid geographic position that has allowed the U.S. to develop almost entirely unmolested by nations which were much more powerful than we were for the first 150 years or so of our history as a nation.
Although national security is frequently cited when justifying the huge amount we spend on the military all it would take to defend our borders is our nuclear submarine fleet to deter anyone from launching a nuclear strike against us, a few warships to help protect our import and export capabilities or attacking us at sea, some fighters and bombers and a land force perhaps the size of the Marine Corps. Except for the nuclear weapons the military would then be reduced to size and role it had prior to both World Wars I and II.
The other reason that nations in general – and our nation in particular – have militaries is to prevent other nations from telling us what to do and get them to do what we want. To understand how this works it’s necessary to look a little deeper at what war is and what it is that nations get from it.
We will begin with a book called On War by Carl von Clausewitz, a Prussian officer who fought in the Napoleonic Wars of the late 18th and early 19th centuries. Clausewitz lived during the Enlightenment, a European intellectual movement which hoped to wean society from irrational beliefs and superstitions. This movement came about as part of the great scientific revolution which happened at the same time. The Enlightenment was, among many other things, an attempt to apply the scientific method to how people thought and acted and especially to their philosophies. In On War, Clausewitz tried to examine and define the theory of war; to look at the why of it and determine what, if any, universal rules and laws it operates under.