Allowing judges to do this would protect consumers from the impact of their own misjudgements and/or the impact of predatory lending policies on the part of mortgage companies. Only the second of these would traditionally be seen as consumer protection, so my answer will focus on that aspect.
One reason for the financial crisis was that lenders often helped get consumers into loans that they could not afford. There were many instances in which the lenders helped consumers falsify loan applications or otherwise manipulate the system to allow them to get mortgages that they could not truly afford. When the housing market stopped going up, many of these consumers found they could not afford the mortgages and could not sell or refinance to get out from under them.
If judges could rewrite mortgage terms, the thinking is that consumers would be protected from these kinds of actions. Companies would have much less incentive to engage in these predator practices because they would stand to get less profit from them after judges rewrote the loans. In this way, the rewriting can be seen as a form of consumer protection, not just as a way to help the economy get out of the current situation in which growth is very low.