The king was allowed to have whatever he needed to run his household - which might come to a great fortune - but he was not allowed to stockpile gold and silver for himself. Once again, the reason is stated by the Torah: doing so will make the king haughty and arrogant. He has this job to take care of the people, not to enlarge his own ego. Allowing the king to have personal troves of wealth would be the surest way to make the job all about him and not about his subjects.
King Munbaz of Adiabene, son of Queen Helena, was a convert to Judaism (and not king of Israel). The Talmud in Baba Basra (11a) tells how he gave all of his personal wealth to charity. When his family complained, he replied, “My ancestors stockpiled material wealth – I prefer to stockpile spiritual wealth!” That’s the way to do it!
This mitzvah applies when the Jews have a king. In the Talmud, it is discussed in tractate Sanhedrin on page 21b. It is codified in the Mishneh Torah in the third chapter of Hilchos Melachim and is #365 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos.