Gold itself only became worth something because the government says it is. Or rather, it became worth far more once governments started demanding that taxes be paid in gold. Before that it probably wasn't worth all that much, because despite its rarity it wasn't useful for much in the ancient world. Gold isn't some magic substance with intrinsic value.
See Debt: The First 5,000 Years by David Graeber.