Proof of Work
The most famous and well-known coins, such as Bitcoin and Ethereum, although their differences, use a consensus algorithm called Proof of Work, in which an extraordinary and expensive computing power is put in place, spent to calculate complex mathematical elaborations, in order to create and validate a block of transactions.
This activity is called mining.
The main purpose of this and other algorithms is to elect a leader, a mining node, who decides the contents of the next block and its transmission to the network, so that everyone can verify and record the validity of its contents.
In order to elect a node as a leader, it is necessary that it finds a solution to a mathematical problem and that all the nodes in the network recognize the correctness of the resolution. In this way, the miner will receive a reward, both for the mined block and for the transaction fees, and therefore it will have an incentive to continue mining.