How does the task of leading military to defend a country provide order for that country?

How does a government provide order for its citizens?