* 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.

Since I see you're from the UK... over there bonds are called [gilts](https://en.wikipedia.org/wiki/Gilt-edged_securities). And here's a [breakdown](http://news.bbc.co.uk/2/hi/business/8530150.stm) of their ownership from 2009 (since that's what I could easily find):

[![enter image description here][1]][1]

> The biggest owners of gilts are insurance companies and pension funds. For them, gilts are predictable investments, which are particularly useful when a low-risk product is needed. Pension funds, for example, will usually switch an individual's holdings from higher risk investments, such as shares in companies, and put them in gilts as the person gets closer to retirement.

> Next on the list comes investors overseas. Unfortunately, nobody keeps records showing in which countries these gilts are held. This is in contrast to, for example, the US, which regularly publishes lists of the countries that own its Treasury Bills. So we know that at the end of 2009, $302.5bn (£196bn) of US government debt was held in the UK, making the UK the third-biggest investor behind Japan and China.

> The next biggest category holding UK government debt is banks, which includes the Bank of England. Since March 2009, as part of its quantitative easing programme, the Bank of England has bought just short of £200bn of gilts, making it the third-biggest holder of UK government debt.

And a more recent (2017) [article](https://theconversation.com/how-vanishing-debt-costs-helped-the-uk-forget-about-a-never-ending-deficit-83321) (although lacking a pretty graph) roughly paints the same picture for UK's debt:

> Traditionally, around 40% of UK public debt was held by pension funds and insurance companies, which form a captive market because of their need for predictable and safe long-term investment returns. Around a quarter was held by other UK financial institutions and households, and the rest by overseas investors.

> QE [quantitative easing] has disrupted this pattern. Now, around a quarter of issued gilts are held by the Bank of England under its Asset Purchase Facility. Official data still show overseas holdings at around 27%, with insurance and pension funds’ share down to 28%, and other UK financial institutions holding around 40%. But once the store of gilts sequestered on the Bank of England’s balance sheet is excluded, overseas buyers account for 35% of gilt holdings and other central banks another 11%.

> Uniquely, more than 10% of the UK’s debt cannot be traced to either domestic or overseas buyers due to the paucity of data from the regular auctions. Lack of clarity on who’s holding the debt makes it harder to judge the risks of buyers selling-off or staying away. That fuzziness that may have helped to keep the markets calm.

* 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. The bonds of the big countries have had somewhat of "miraculous" negative real interest rate in the short run [recently](https://theconversation.com/how-vanishing-debt-costs-helped-the-uk-forget-about-a-never-ending-deficit-83321) (although lacking a pretty graph):

> UK national debt is currently issued at a yield of less than 1% – far below the rate of inflation (2.6% in July). And this means Britain can effectively raise money free of charge in real terms. [...]

> So why are UK bonds still flying off the shelves, allowing the government to plug the gap in its spending plans with virtually “free” money? It is possible that investors are snapping-up new gilts simply through a lack of alternatives. If (as some fear) overpriced stock markets and property are about to crash and once-buoyant emerging markets are in trouble then the public debt of stable rich countries becomes the least worst option. US and German debt issues are proving similarly popular at rock-bottom yields.

Although this year the bond rates [are expected to tighten](https://www.reuters.com/article/us-global-markets-realyields/commentary-policy-tightening-its-real-rates-that-matter-for-markets-idUKKBN1EY15R), they are still mostly negative in real terms (for the big boys, but not so much for the smaller fish with weaker economies; the exception being the US which slighly above zero):

[![enter image description here][2]][2]

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.

  [1]: https://i.stack.imgur.com/jyJL4.gif
  [2]: https://i.stack.imgur.com/A7Nls.jpg