With government-issued currencies (fiat currencies) like the USD or EUR, a central authority such as a government or central bank has the responsibility of, amongst other things, keeping track of the currency in circulation and controlling the production of new currency.
In Bitcoin and some other cryptocurrency networks, miners replace the role of the central bank: securing the network, controlling the supply of new coins, and confirming that all transactions are valid (for example by ensuring coins are never 'double-spent'). Miners are participants on the blockchain who validate the authenticity of new blocks (and the transactions contained within) by solving complex mathematical puzzles.
The first miner to find a solution for each new block is rewarded with a set amount of the network’s native cryptocurrency, BTC on the Bitcoin network or ETH on Ethereum, for example.
The solution is broadcast to all the other miners, >50% of whom must then agree that the proposed block is valid. The fact that miners spend real-world resources, such as processing power and electricity, to confirm the validity of new blocks gives them an incentive to work in the interests of the network; in order for the rewards they receive to be valuable, they must ensure the reliability and security of the network.
No individual miner has the power to game the system, given that the majority of miners must agree on the validity of each block. This means that to act in a malicious manner, one would have to gain control of over 50% of the total mining capacity of the network (known as hash power), something that would require enormous amounts of processing power and electricity.
The consensus mechanism described above is formally known as Proof of Work (PoW), and participating in the consensus of a PoW blockchain, in order to earn rewards, is commonly known as mining. While PoW was one of the earliest implemented types of mining, there are a number of others present in the public domain today, such as Proof of Stake (PoS) and Proof of History (PoH).