According to this book
One major question needs to be answered. Why should al-Baghdādī and Ibn al-Qiftī make up the story about Amr’s burning of the Ancient Library of Alexandria at the order of Caliph Umar ibn al-Khattāb? El-Abbadi argued that after Saladin overthrew the rule of the Fatimids, he found himself in dire need of money to carry on his campaigns against the Crusaders and to pay off those who had co-operated with him and served him. He therefore donated as well as offered for sale many of the treasures he had confiscated; we know that among these treasures, were great public libraries of the Fatimids. Consequently, the destruction of the ancient library of alexandria there was a widespread feeling of resentment and discontent at the loss of such priceless legacies of learning. Saladin was accordingly exposed to bitter criticism, especially by the survivors of the old Shiite regime whom he sought to suppress.
To defend such an action, Ibn al-Qiftī, who was a close associate of Saladin, wrote this fictitious story to show that selling when in need, is a lesser crime than the burning of pagan books as Umar did.