I'd argue that the purpose is to act as a deterrent against countries that might otherwise think of invading their neighbors or things along those lines, but it's reasonable to think that the cost of such of large military is not worth the benefits.
It's also one of the US's largest employers.