Why do banks need to write-off the debt against Shareholders capital invested I have seen the basic equation that rules this system:

$$ Assets = Liabilities + Equity $$

@Alecos Papadopoulos has a really great answer that totally makes sense for this question.  But, I would like to ask, why does the bank need to write-off the debt against Shareholders capital invested?  Why cannot they act like the Pope and say, "I forgive your debt" then move on and not write off the shareholder's capital?  Would this not be better for everyone?

Further, I have read Jeffrey Sachs has argued for debt forgiveness for developing countries that have trouble paying back their debt, is this a similar situation replacing Person $A$ with country $A$?
"Double-entry" bookkeeping is the resulting methodology of the fundamental approach of Accounting science to what a productive mechanism does (be it a company or whatever): Accounting perceives productive entities as mechanisms to transform capital from one form to another, irrespective of what their economic goal is for doing this (profits, charity, whatever).

The Liabilities+Equity side shows "how much capital and from whom" has  the firm sourced and put it under its control, and the Assets side shows to what forms the firm has transformed this same capital . But if it is the same capital, it necessarily has the same value : this is why accountants write the same number twice: they write it once and link it to a code that shows from whom did the firm get this amount of capital, and they write it a second time and link this to a code that represents to what has the firm transformed the capital.

So I took a capital of 1,000 from a source called, say, Shareholders, (or Deposits, or a combination) and transformed it in another form of capital called "Loans to customers". I write the number down two times, one linking it to the code that Shareholders have, and a second time to link it to the code that "Loans to customer has".  

At the same time "Liabilities + Equity" shows how much capital must the firm return back -because in the theoretic Accounting model, the company itself "owns nothing", it is just a capital transformation mechanism. It may has capital under its control, but it has eventually to return it.

Now the customer appears and says, "no payback". It is the same thing as a fire destroying a building - an amount of capital has been lost. So the company can no longer return it. Given the general legal/social arrangements, in such cases, irrespective of the actual source of capital (say, Deposits), those who will now must expect to get lower capital back, are the shareholders. So the double-entry write-off of the bad loan reflects exactly that fact: "I, the transformation mechanism, inform the world that a) I just lost an amount of capital and consequently that b) given the rules, my shareholders have now a lower claim from me, as regards the return of capital to them".

Not doing this, won't "be better for everyone", because it would be misleading - by looking at the bank's book, the shareholders would still expect to receive back their 1,000 investment, but they would eventually find out that only 100 are there in reality.

I hope that helps.