I'd say gold has retained its value because (in no particular order):
1) It's bright and shiny
2) It's (almost) infinitely divisible, and can be readily poured into a fixed volume
3) It's durable and resilient
4) You can pack a lot into a small space
5) They're not making any more of the stuff (well, it can be mined, but this only adds a tiny bit at a time to supplies, year over year)
6) There's no technology on the horizon that would enable gold to be made from anything else at a cost that would even remotely make sense
7) Because almost everyone agrees it has value
I may be repeating some things that have alrady been said but this topic interests me, enough so that I took an independent course on this subject last year, studying "essential nonessentials."
This list sums it up pretty well. Gold is unusual in being nonreactive, so that all the gold ever mined basically still exists somewhere right now. In addition, it is not particularly useful. It's too soft to do much of anything that's not decorative with it, so it is not being used up in practical things. Gold is difficult to get, it has to be mined, but is distributed fairly well over the entire earth, meaning that all cultures had some exposure to it.
I think gold gained early fame because of the fact that it does not react, and therefore does not tarnish. This associated it with eternity, and so people tended to associate it with divinity and religious things, rulers sought it out to connect themselves to the divine. It therefore became associated with a sort of privileged prestige, that as the world democratized everyone wanted a part of.
When gold became a form of currency that pretty much decided its future. It's interesting to imagine what would have happened if people had settled on another metal for this. Gold retained value in Asia despite not being used as metal, but this was driven by a very privileged ruling class that hoarded it for that prestige value. However, the value of gold and then the finding of gigantic amounts of it in the Americas led to a huge boom that coincided with the increasing use of it as metal, so everything remained in sync. If Asia had rejected gold and silver, things would have happened very differently, perhaps we would not have mined so much gold and its value would still remain high.