The Spanish destruction of Mesoamerican books was systematic rather than incidental. Missionaries treated the painted manuscripts as instruments of idolatry and burned them in quantity; Diego de Landa's burning of Maya books at Mani in 1562 is the best documented episode, but the practice was general across the conquered territories, and native lords destroyed or hid books themselves once possession became dangerous. The result is that of a manuscript tradition which must have run to many thousands of volumes, only a handful of pre-conquest books survive anywhere in the world, and they are counted one by one.
The Codex Borgia's own history before the eighteenth century is blank. It is named for Cardinal Stefano Borgia, in whose museum at Velletri it is first securely attested, and it passed with that collection to the Vatican after his death in 1804, reaching the Apostolic Library itself in 1902. Two accounts circulate of how it came to Europe: an oral tradition at the Congregation for the Propagation of the Faith that it was rescued in 1762 from a burning in Mexico, and a story reported by Alexander von Humboldt that it had belonged to the Giustiniani family in Rome, was damaged by fire in the hands of neglectful servants, and was retrieved by Borgia. Both are accounts given rather than established fact, and neither is independently documented.
Whichever is nearer the truth, the point stands. The survival of the single most important source for central Mexican religion was accidental, and by both accounts a near miss.