The relative values are based upon tradition ... the prices are very similar to Gygax's own list in the AD&D rules, which is an expansion of the material in the original D&D game.
Gary Gygax, however, probably did not make them up on the spot. In comparing various price lists in various games, Gary's numbers routinely come up around 1gp equaling one roughly 11th Century shilling. Looking at Hodges' list ①, most of the prices come pretty close.
Medieval English Coins
A few words about medieval English Coins; they were specie. The values were based upon weight and purity, and the rosy picture of relatively stable prices and uniform coins are an artifact of Fantasy. The nominal base units were the penny (1 dwt of silver), the shilling (12 dwt of silver), and the pound of silver (240 dwt). Gold coins of roughly equivalent value were used. The "gold penny" was a 1dwt coin of gold (debased with copper, tin, and zinc), nominally worth 12 to 20 pence. It was generally accepted as 12 pence, hence a shilling's value - but often was valued more.
Note also: dwt (pennyweight) is a part of the troy measures system - 20 dwt to the troy ounce, and 12 trounces to the troy pound.
With the above considered, the GP probably has its origin in the gold coin nominally worth 1/20 of a pound of silver. 12 dwt is about 18.67 g, 3x modern £1 coin (within 0.2g). Not a light hunk, but still less than the current £5. And the current UK penny is roughly 2.3 dwt.②
5E returns to the "everyone but Gary & Tom" 50 coins to the pound. We don't know which pound, so we'll assume avoirdupois, at 291.67 dwt. This converts to 5.834 dwt to the coin, or about 9.1 g. This is about the same as the current UK £1, or 4 US dimes. If we instead use Troy Pounds, at 240 dwt each, 4.8 dwt is 7.4g, a touch lighter than the 50p or the US current presidential dollars.②③
Knowing that the gold penny was roughly 1 shilling in value at lowest, we can see where it originates. The fantasy weight of 1/10 pound (in some editions) and 1/50 pound (in the rest) is probably because of looking at debased silver shillings (12dwt) and copper pence.
So, some specific examples, compared to Hodges list.
Wine, hodges lists at 4d to 8d per gallon (1/3 to 2/3 of a shilling), while 5E lists it as 2sp to 10gp... so, 1/3gp to 2/3 GP, vs 1/5 gp to 10gp. A wider range. Probably not the same source, but clearly includes the Hodges range if a shilling is a gold.
Tunics, peasant. Hodges says 3s, with shoes 6d and a chemise 8d.
5E shows half a gp for common, 2gp for travelers, so, yes, we're in the ballpark
Axe, woodsman's - 5d by hodges, 5 gp by 5e.
University boarding: 2s/week, by Hodges, 1.8gp/week for poor by 5E. Close enough.
The only armor which is a clean match is leather at 5s being 5gp. The others, however, are in similar ranges.
A cheap sword in Hodges is 6s, so that would be 6gp, but D&D traditionally uses 10gp.
In short, the list is close enough that it looks like, between Gygax's original research for D&D and AD&D, and modern reworks, the prices are taken from scholarly lists of prices from the medieval period in England and France, both of which used similar currency divisions (£, s, d).
If expanding the lists, keeping in mind medieval sources can help keep the prices roughly in line, and that any given list is neither authoritative nor more than just a snapshot.
① Hodges, Kenneth. List of Prices of Medieval Items
② Royal Mint. Coin Designs and Specifications
③ United States Mint. Coin Specifications