The government would have made more if it allowed the people to sell the coins, and then pay income tax on the proceeds.
Instead, the IRS threw away a chance for a few million in revenue.
As others have noted above, this was part of FDR’s very controversial decision to take the country off the gold standard in 1933-34. He knew people would flock to gold rather than trust paper money. So he had to outlaw the private ownership of gold in the US (with a very few exceptions). This stayed on the books until 1973.