Chinese leader Xi Jinping has purged dozens of military commanders in his latest bid to wipe out corruption and disloyalty—a scourge he blames on a weakening of ideological zeal and moral rectitude.