Central banks are set up for many different reasons. The Bank of England was set up to fund the war efforts of the King. The Federal Reserve was set up after the 1929 Wall Street crash to manage the financial system.
In Malaysia, Bank Negara is set up to be a custodian of foreign reserves and to protect the value of the currency, apart from being a banker to the government.
The central bank technically wants all citizens to surrender their foreign currencies to them in exchange for the ringgit that they print. As a result, the central bank ends up holding (m0st of) the foreign currencies of the people, ie the nation.
Foreign currencies are the currencies of foreign countries, and they cannot be used locally (by definition - although people are now allowed to keep foreign-currency deposits.
With the foreign currencies, the central bank tries to invest it. Most are inclined to keep cash with the respective central banks - for safety.
Sometimes, central banks do get greedy and try to earn extra interest income on their foreign currencies - and they usually get burnt. The adventurous ones invest in bonds or shares or real estate.
But the foreign currencies do not belong to the central bank - the central bank is merely holding the foreign currencies as custodian for the nation.
Technically, whoever needs foreign currencies can always buy from the central bank - who usually delegates the authority to the banks to help in providing the service.
If few people want foreign currencies, the exchange rate will be low.
If many people want foreign currencies and if there are not enough foreign currencies, the price of the foreign currency goes up and the local currency depreciates.
Depreciation is just a way for the central bank to conserve its limited foreign currencies.
If the central bank is persuing a policy of fighting imported inflation and does not want to the currency to depreciate, it will have to buy up lots of its own local currency in exchange for the foreign currencies.
This problem usually arise when the central bank prints too much money or that there is a loss of confidence in the local currency and people want to hold more foreign currencies.
When the central bank prints too much local currency, the value of the local currency falls.
When the central bank does not know what to do when there is massive exodus because of excessive printing of money or loss of confidence, the unschooled policy is to impose foreign exchange controls. There is no heroism here.
Foreign currency holdings are not national savings. National savings are reflected in the national investment. A lot of cash in the system with little investment is a sign of trouble in the economy. No future.