It is narrated from Sayyiduna Abdullah bin Amr (may Allah be pleased with them both) that the Messenger of Allah (peace and blessings be upon him) said: "Every debt will be paid (in recompense) from the good deeds of the debtor, except in three cases: a man who became weak in the path of Allah, so he took a loan to gain the strength to fight his enemy, then died and could not repay it; a second man who feared for himself the state of remaining unmarried, so he took a loan to marry and thereby kept himself chaste, then died and could not repay it; and a third man with whom a Muslim died, and he found nothing to shroud him with except by taking a loan, then he himself died and could not repay it. The debt of these three will be paid on their behalf on the Day of Resurrection."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 13771