* How does a country get so far in debt, and who is it in debt to? 

Mostly because of government-issued bonds. These can be held by other governments, private entities or even the various government agencies: [In the US](https://www.thebalance.com/who-owns-the-u-s-national-debt-3306124), starting with the last category:

> Intragovernmental Holdings. This is the portion of the federal debt owed to 230 other federal agencies. Intragovernmental holdings total $5.6 trillion, almost 30 percent of the debt. Why would the government owe money to itself? Some agencies, like the Social Security Trust Fund, take in more revenue from taxes than they need. Rather than stick this cash under a giant mattress, these agencies buy U.S. Treasurys with it.

> Debt Held by the Public. The public holds the rest of the national debt of $14.7 trillion. Foreign governments and investors hold almost half of it.

* How can countries of the world operate owing such vast amounts of money?

It depends on the country. Countries whose currency is attractive enough, e.g. the US dollar can "get away with it" by "printing" more money (see [quantitative easing](https://money.cnn.com/2016/05/11/news/economy/donald-trump-print-money/index.html)), although they can't do that too fast because that can cause inflation.

Countries whose debt is denominated in a foreign currency, or a currency they can't print for some other reason, e.g. being in monetary union (ahem, Greece) can be in a world of hurt if they suddenly are threatened by default (inability to pay back on schedule). Typically the IMF steps in but it also [imposes conditions](https://www.imf.org/en/About/Factsheets/Sheets/2016/08/02/21/28/IMF-Conditionality) in terms of structural reforms etc. for their bailouts.