American involvement in Afghanistan is “a war of necessity” — not of choice — President Obama said in a speech to military veterans.