Gold is a rare earth metal and has been used as coins or accessories by civilizations for hundreds of years. It is malleable, does not corrode, a good conductor of electricity and features a very attractive appearance. However the value of gold is somewhat psychological. Other than gold jewelry, gold is used in electronics because it is very conductive of electricity. It is true that gold is rare which contributes to its value, but being rare is not the sole reason for the current value of gold. Before paper money is standard around the world, countries use gold as a medium of exchange. Gold prices do not always go up in value their values also crash just like stocks and other commodities. As a medium of exchange, if a country's economy is expanding, the need for gold increases to facilitate trade and since gold is mined, a shortage of which causes an economy to contract and in turn increases the value of the precious metal.
Whenever a new mine is found, an influx of gold would flood the market and its value would then decline as there are more gold available than the goods it can buy. This is evident in the 1500's when the Spanish empire brought back enormous supply of gold from mines throught its colonies in Mexico and the rest of South America. Global economic growth will always surpass the rate at which gold can be mined and as a result, ugly economic contractions are rampant.
Nowadays, the fiat system completely severed its ties with gold and the medium of exchange is now shifted on printed paper backed by people's perception of a country's economic health. Since gold was once used as a primary medium of exchange throught the ages, combined with its characteristics, it is traded as a commodity and its value rise and falls opposite to the value of most global currencies. The value of gold now depends on the supply and demand of speculators buying it as a hedge to a weakening currency or an economic collapse. It is also backed with an intrinsic value where it can be used in the semiconductor industry. Ultimately, the perception of the herd is what dictates the value of commodities.