Transactions on the blockchain must be verified. The verification is done when cryptographic calculations are solved. Solving these sums requires CPU or GPU processing power, a lot of processing power. Solving these sums is called mining. This type of consensus is called Proof of Work.
The transaction with information such as how much crypto and from and to whom is written per block in the ledger of the blockchain. The miner receives a reward for solving the maths and making his/her equipment available. Miners keep the financial eco system alive, because no miners no verifications. When the maximum supply crypto is reached, meaning no coins or tokens to reward miners, the reward system of mining will be transferred to payment per transaction by the person using the transaction.
The computing power of mining costs a lot of energy and energy costs money. It can be lucrative when the rewards of mining are higher than the investment of equipment and the final bill from the energy company. With bitcoin the profitability becomes less and less, because of the degree of difficulty and in general because of the value of a crypto and the energy costs that are pretty high in the Netherlands.
If you are considering mining, there are complete sets, including Bitmain and INNOSILICON, which are specifically made for a particular cryptography. These miners make it somewhat easy to get in as a starter.