Gold is fungible, as in easily divisible and extremely malleable.
Gold has excellent electrical properties and doesn't suffer from oxidation/corrosion like most forms of silver and copper. How many electronic devices would cease to operate without some form of gold?
Gold is extremely chemically stable (see corrosion/oxidation) and is rarely consumed in industrial usage. It is non-toxic (other than radioactive isotopes and gold salts) and can be eaten without issue.
There's only so much gold until someone figures out transmutation, as heavy elements like gold are created inside stars. The total amount of known/estimated gold in the world would fill a pair of olympic swimming pools.
If gold weren't so rare, it would be used anywhere that lead or copper is used. Our plumbing would all be gold alloy, all our wiring would be gold alloy, all our bullet ballast would be gold rather than lead, our lead acid batteries would be gold acid based.
Finally... if you really want to know why gold is valuable, look at it this way: for every ounce of gold you see, there were X millions of joules of energy required to smash hundreds or thousands of tons of ore to create one pure troy ounce. Each ounce of gold represents
immense amounts of energy expended.
All of this means beans though. The real reason why gold is valuable?
Because women love shiny objects and men will do anything to please them!