Armed forces (army, navy, air force, national guard) provide for the common defense (as the Preamble to the Constitution says).
They protect the country from foreign invasion, or from attacks on its trade, and domestically provide a means of suppressing rebellion, insurrection, or civil disobedience.