Al-Qurtubi (may Allaah have mercy on him) said: “What is the reason why the legacy is mentioned before the debt, when the debt takes precedence according to scholarly consensus, i.e., the debts of the deceased must be paid off from his estate before his will is executed… this may be answered in five ways:
1 – What is meant is that these two issues take precedence over the issue of inheritance, and the order in which they are mentioned is not indicative of which one is more important. Hence the bequest was mentioned first.
2 – Because the legacy is less binding than debt, it is mentioned first to show that it is nevertheless important, as when Allaah says (interpretation of the meaning):
“What sort of Book is this that leaves neither a small thing nor a big thing…”
4 – The legacy is mentioned first because it is the share of the poor and needy, and the debt is mentioned second because it is the share of the lender who can seek it with force and who has a strong argument to support his case.
5 – Because the legacy is something that is initiated by the person, it is mentioned first, whereas the debt is something that is well established and clear whether he mentioned it or not.
See al-Jaami’ li Ahkaam al-Qur’aan by al-Qurtubi, vol. 5, p. 74.
Some scholars added two extra points:
“The legacy is mentioned first because the legacy is an act of kindness and upholding family ties, unlike the debt which usually results from a kind of neglect. So the phrase starts with the legacy because it is of greater virtue.
And it was said that the legacy is mentioned first because it is something that is given for nothing in return, whereas the debt is given in return for something. So payment of the legacy is harder for the heirs than payment of the debt, and paying the legacy may be thought of as a form of waste, unlike the debt which the heir will pay with condifence.”
See al-Tahqeeqaat al-Mardiyaah fi’l-Mabaahith al-Fardiyyah by Shaykh Saalih al-Fawzaan, p. 27.