1. Gold is a store of value. It is wealth. It can not be created out of thin air the way a central bank or government can decide to print $1 trillion in currency. When a lot of new dollars are created, it means the value of each particular dollar is less. That means the price of everything you buy goes up. That is inflation in prices. It's also a deflation of the value of the currency.
When currency goes down in value, people look for safer investments. Gold (and other precious metals) become more in demand, as more people look to have real wealth instead of paper. So this increased demand makes the price of gold increase. Combine this increase with the inflation in prices caused by printing more money and you have double the reasons for gold to rise in value.
2. When your return on investment is less than inflation, then you are losing money. If I have money in the bank and I make 5% interest on it, but prices rise 10%, then I have really lost 5% of my wealth. My money is worth less now (can buy less) than it was when I put it in the bank.
Whether investments are in real estate, stocks, bonds, whatever, if inflation is so bad that the real rate of return in negative (as I described above), then people look to put their investments in safer places. The money flees (runs away from) the losing investments to safer places, like gold.