Some related situations:
The tower of London or other similar fortresses and castles were used to store money. The crown jewels are still stored there.
Obviously, "Quis custodiet ipsos custodes?" is an old problem, but they had, e.g., locks with could only be opened with 2 or more different keys. One example, during the famous indulgence controversy around Martin Luther time, the money chests always had 2 keys held by different persons, to avoid abuses.
The Templars transported money for the king (e.g., moving a chest full of gold coins from Paris to somewhere in France to pay soldiers during a war). The Templars charged a fee for this service, as they always needed income to finance their own army in the Holy Land. Presumably, the King trusted a knight's oath more than his own soldiers.
Another common situation is not to have any large treasury to be guarded. Portugal was in debt for long periods, thus any income would be quickly expended and there were no really large reserves, only current income/payments flows - i.e., bankers were the reserve and the real big money was in the banks.
For example, after 30y of deadlocked war against the Dutch in Brazil, the king made a conscious decision of borrowing money all around Europe - knowing that it would take decades to pay back - to break the deadlock by financing the army that kicked the Dutch from Brazil in 1650. Do not expect a large royal treasure in Portugal for the next decades - the bankers had everything - a thief would rather dream of robbing the Fuggers than the king.