Mining is the process of building the blockchain by adding new blocks one at a time. First, miners build a block by collecting many unconfirmed transactions from the mempool. This is a relatively simple step. Next, miners search for a Proof-of-Work, or a valid hash of a block. This is essentially an energy-intensive guessing game.
Once a miner has found a valid hash, they submit the block, along with the valid hash, to the network. New bitcoin are minted through the process of mining as compensation for the intensive work of finding a valid hash. This new bitcoin is called the mining subsidy, and it helps miners pay the cost of finding a valid Proof-of-Work, which requires immense energy expenditure.
Miners have no better way to produce a valid hash than by guessing and checking the validity of each hash, and so they attempt to make as many guesses as possible while using as little time and energy as possible. The rate at which miners guess is called their hash rate, measured in hashes per second. The cumulative hash rate of all Bitcoin miners is an important metric for determining Bitcoin’s security, as it indicates how much hash rate an attacker would need in order to execute a 51% attack.