Saudi Arabia’s monarch ordered a far-reaching shake-up of its armed forces to strengthen its military amid a drawn-out war in Yemen and efforts to contain Iran’s influence in the Middle East.