To get gold, you need to get it. It takes the time of people who are directly involved in this. As a result, a kilogram of mined gold can be equated to the man-hours required for its extraction and further used as an equivalent of free labor, i.e. currency.
Something similar is happening bitcoin with credit card. The number of «coins» is limited to 21 million. When the total supply of bitcoins reaches this value, any further emission will cease to prevent inflation. And mining bitcoins requires certain costs. If in the case of gold mining takes human labor, the mining of bitcoins takes the «labor» of a computer.
If for the extraction of gold a person must take the rock, wash it and thus separate the gold from everything else, then for the extraction of bitcoin the processor needs to solve a number of mathematical problems. If the result meets all the criteria, bitcoin is created. By the way, the process of mining cryptocurrency is called «mining».