The first reason countries maintain large militaries is that nation-states cannot be too optimistic – they must be prepared for armed conflict and develop military capabilities according to their own unique threat environments. But the second reason is that national militaries often help maintain national unity.
https://geopoliticalfutures.com/the-political-nature-of-strong-armies/