Cryptocurrency mining is a way to get Bitcoins. Of course, it is possible to buy them, but Bitcoin mining creates new ones by making new parts of the blockchain. In defining cryptocurrency mining, it should be stated how it actually works. In order to mine, there must be a peer-to-peer computers network so that tasks can be performed with their combined computing power. The more computers and less centralized the system, the faster tasks will be operated. Each computer is called a host in the blockchain and the network works based on a cryptographic protocol. By recording and confirming new operations into a virtual, replicated, and distributed public database known as the blockchain, miners (those who do mining) create new parts of the chain and they receive 12.5 Bitcoins for each new part as a reward.
The new block can be made just once in 10 minutes so that to synchronize all operations, assure they are mathematically accurate and be able to spread it around all users.
When you hear about bitcoin "mining," you envisage coins being dug out of the ground. But bitcoinisn't physical, so why do we call it mining?
Because it's similar to gold mining in that the bitcoins exist in the protocol's design (just as the gold exists underground), but they haven't been brought out into the light yet (just as the gold hasn't yet been dug up). The bitcoin protocol stipulates that 21 million bitcoins will exist at some point. What "miners" do is bring them out into the light, a few at a time.
They get to do this as a reward for creating blocks of validated transactions and including them in the blockchain.
Backtracking a bit, let's talk about "nodes." A node is a powerful computer that runs the bitcoin software and helps to keep bitcoin running by participating in the relay of information. Anyone can run a node, you just download the bitcoin software (free) and leave a certain port open (the drawback is that it consumes energy and storage space – the network at time of writing takes up about 145GB). Nodes spread bitcoin transactions around the network. One node will send information to a few nodes that it knows, who will relay the information to nodes that they know, etc. That way it ends up getting around the whole network pretty quickly.
Some nodes are mining nodes (usually referred to as "miners"). These group outstanding transactions into blocks and add them to the blockchain. How do they do this? By solving a complex mathematical puzzle that is part of the bitcoin program, and including the answer in the block. The puzzle that needs solving is to find a number that, when combined with the data in the block and passed through a hash function, produces a result that is within a certain range. This is much harder than it sounds.
(For trivia lovers, this number is called a "nonce", which is a concatenation of "number used once." In the case of bitcoin, the nonce is an integer between 0 and 4,294,967,296.)
The difficulty of the calculation (the required number of zeroes at the beginning of the hash string) is adjusted frequently, so that it takes on average about 10 minutes to process a block.