What is the literary or historical origin of the term "gold piece" to mean a gold coin? Was it used before D&D, or did D&D coin the term?
The term definitely predates D&D - the term "twenty dollar gold piece" has been in use for the $20 Double Eagle and $10 Eagle coins of the late 19th century, and also the $5 gold coin, as well.
"Gold Piece" In Print
The term is used in the Lebanon Daily News, 1 Nov 1965, of Lebanon, Pennsylvania, bottom, in an advert for old coins under the left column of text (to the right of the comics)
This alone establishes the phrase "gold piece" for gold coins in routine use prior to D&D. But let us press a little further back... say, 1913? Here's a quote from the 5 August 1913 Cedar Rapids Evening Gazette, from Cedar Rapids, Iowa, page 4, top of the third column:
We thus have established a pattern of use for gold coins of being called "gold pieces" in the press, spanning over 5 decades; clearly not a D&D origin; not even viably a wargaming origin, for 1913 is the year of the first printing of H. G. Wells' Little Wars, the first commercially released set of wargaming rules in book form.
Searching Project Gutenberg, several ebooks have it in use...
These without clear denomination prefixed:
And several with clear denomination in dollars:
It's pretty clear that it's a generic term for a gold coin, and for several US gold coins as well. In the US, it seems to be predominantly the popular $5 coin of the late 19th and early 20th centuries, but can be used collectively for the $2.50, $5.00, $10.00 and $20.00 gold coins; The silver coins of similar values were $0.10, $0.25, $0.50, and $1.00. Note that, still to date, "2 bits" is $0.25... a reference to the not uncommon practice of breaking Pieces of Eight (Dollares, or Reals) into 8 "bits" of an eighth-dollare each... I suspect that this is the origin of the 20:1 Silver:Gold ratio in AD&D...
Let's ask the Wiktionary.
It seems to be quite an old term:
I would say it is of historic origin.
Here in Sweden we had gold (and other valuable metal; copper was the most common) pieces that was simply weighed and that could be cut up if needed before we had coins.
At first it was simply a big hunk of metal later on it became "standard" sizes with stamps that guaranteed the weight and then after that came the coins (as we know them).
The most important historical precedent for parceling gold into "pieces" is Robert Louis Stevenson's Treasure Island (1881), an enormously popular work of fiction that was plundered and imitated by many authors in the following decades. While that work is more famous for the construction "pieces of eight," Treasure Island exemplifies usages like "pieces of gold" throughout to refer to pirate treasure. These precedents informed countless subsequent authors, especially authors of fantasy fiction, including Howard and Leiber. Conan, for example, knows of "men willing to sell their souls for a few gold pieces" in the 1930s. It is surely these usages that ended up informing the vocabulary of Dungeons & Dragons, as the authors of D&D cited these works specifically as influences.