D. to protect against future Mongol invasions
Yongle moved the capital from Nanjing to Beijing primarily to enhance the security of the Ming dynasty against potential threats from the Mongols to the north. Beijing's strategic location allowed for better defense and control over the northern frontier.