Core Question
Central banks are buying up gold at a extreme rate, even though they have national debt. Why is that?
Background
Out of all the countries, even the ones not buying gold, the average accumulation per month is about 91 tonnes (metric) per month (that is 200,620.693 lbs. of gold per month per central bank on average). That is about as heavy as a Boeing 737-800 loaded with full passengers, cargo, and fuel. And keep in mind that the 737-800 carries about 160-189 passengers depending on the configuration. So, why exactly are central banks buying this much gold?
Reasons for
Central banks are buying gold to hedge inflation. That is the most straightforward answer. For example, India is buying a ton (no pun intended), and they have an inflation rate about 4.8%. Another example is Turkey. They are also buying a ton of gold, and their inflation rate is at about 31.5%. Of course, not every country is like that, but, these are some great examples. What I find ironic is that these central banks are buying gold to hedge against a currency they themselves put inflation upon. (Not totally, but their policies still have a huge impact).
Another reason is to diversify away from the US Dollar and to protect against geopolitical risks. In fact, gold has become the most held asset, surpassing US Treasury bonds. Due to all the conflicts happening in the world - not just the Strait of Hormuz but also other conflicts - have pushed countries to not trust foreign countries as much as in the past. So gold seems like the obvious answer. High value density, matches/beats inflation historically, and has huge demand.
Reasons against
Of course there are reasons that central banks should not be buying gold. One of those is debt, most simply put. Skyrocketing government debt is not too good. Of course you need debt to survive, but too much is not good. So, countries are buying gold with money they don't always have, forcing the debt even higher. And, with the less interest in foreign bonds, governments can't easily get the funding. So it is like a double sword.
Another reason is that gold just sits there. If you were invested in a bond, then you'd receive interest. Gold just ties up your capital and is an expense until you sell it. Yet, they are still buying up gold, so is there a conclusive answer as to why?
The Answer
The answer is that central banks are betting that if they invest in gold, they'll lose less that if they were to have a ton of other government bonds. That's because you can't control other governments. But you can control what you have in your hands, so it is safer. This is like the whole paper gold and silver vs the actual metal. You can hold the electronic version, but if the platform (the country) gets hacked (sanctioned or similar) or runs out of liquidity (government default), then you have claims on worthless assets. Same thing here. Gold is looked as safer than other governments, and as a way to hedge inflation and other geopolitical problems.
Of course, this isn't the entire story nor the entire reasoning, otherwise I'd be here for 1 week while you'd be reading for 10 hours (and I know that most people skim) :) So, this is cut down, but the core is the same.