Debt is exists to increase efficiency in a certain situation. Namely when there is idle production capacity because of a lack of resources and simultaneously an excess of resources because production capacity has been fully utilized somewhere else.
Person A needs a computer, electricity and access to the internet to run his software company.
Person B manufactures computers.
If you want to maximize economic efficiency then person B has to give his resources to person A. But why would person B do that in the first place? Of course, to make money. So person B will charge person A but person A can pay at a later time, when he has a stable income. That's debt.
What about electricity and internet? Instead of making a deal with every person directly you can increase efficiency of debt by denoting it in the money needed to buy the product or service. Person B lends you $2000 and sells his product for $1000. You spend $1000 and get a computer. As long as person A earns enough money to pay for the computer and the electricity and internet person A consumes then person B will be better off.
As long as person B has spare computers he can keep lending them out in the form of dollars. If person B doesn't have enough computers for everyone he will instead allocate his computers to the highest bidder.
Now introduce person C who does the same thing as person A but promises to give 20% more money than he borrowed. Person B wants the highest possible return for the loan and thus lends the money to C but he also would lend to A if he had enough spare computers.
Now lets take the macroscopic perspective. The government is a giant borrower. It can borrow resources that exist in the economy, but only if they actually exist. One very valuable resource is labor. If there is unemployment you can borrow until all the labor is actively used. Once you have reached full employment any money you borrow and spend on labor will directly translate into inflation. Mild inflation of 2% is necessary to have a well functioning economy.
What does inflation do? The free market is basically a continuous auction that allocates resources to the highest bidders. If there is lots of demand for labor then inflation will go up. The question is whether the labor is spent on economically useful work. Private borrowers tend to use the borrowed money carefully and with the intention to turn a profit so if inflation goes up slightly too much (think of 5%) then they will just allocate their workers to the most efficient use. This is basically solving the problem of too much bad debt automatically.
However, what if you are insane and keep borrowing money despite hitting 2% inflation goals? If you are debt ridden Germany after WW1 then you are forced to spend the borrowed money on war reparations. Meaning, lots of people will start working on undoing the damage the war has caused. The problem with that is that working for the government can end up being so "profitable" compared to private industries that those industries get neglected. This can be a very big deal if that private industry is the agriculture sector.
Summary? You can borrow and print money as long as you spend it wisely and hit your 2% inflation target.