Mining is the term used for creating new coins for a cryptocurrency. It’s also the term for verifying, validating and recording confirmed transactions on the blockchain.
Those two activities are parts of the same thing: miners verify and confirm transactions, then get new coins as their reward.
Bitcoin mining uses “proof of work” (PoW) to confirm transactions. The miner’s computer grinds through a massive pile of complex cryptographic calculations until it gets a result. If it’s the first one with the right answer, it tacks the new block of transactions on the end of the blockchain and earns some coins (and a virtual pat on the head).
Bitcoin increases mining difficulty regularly, increasing the computer power demands over time. That’s why you can’t mine Bitcoin with your desktop any more: it’d take too long and some rich miner with a dedicated ASIC will beat you to it.
Bitcoin mining rewards halve every few years. The last bitcoin will be mined some time in 2040.
Some altcoins are specifically designed for CPU or GPU mining: Monero’s the big boy in that area.
Many people use mining pools. Everyone with crappy CPUs gets together to mine coins, sharing the calculations among them, in an attempt to beat the big players to the rewards. It works.
There are different mining methods, too.
Proof of stake (PoS, which isn’t “piece of shit” in the crypto world) uses your existing coin balance to do a round-robin sort of approach, which is less power-intensive and generally fairer. Hold some coins, leave your wallet staking, earn rewards. Like bank accounts.
Proof of burn and proof of activity are also around, but less common.