07/09/2022
Whenever a Bitcoin transaction is sent a permanent record is made and stored on a public ledger. To ensure accuracy and prevent fraudulent entries, each recorded transaction references the prior transactions. This means that if someone tries to insert or change a transaction it breaks the sequence as the other transactions which follow will not be referencing this fraudulent or altered transaction. To keep this transaction referencing method from becoming unwieldy over time, because at this point each transaction would need to reference the billions of transactions before it, the transactions are separated into groups called Blocks. Each block contains between 2000–2500 transactions on average so this keeps the transaction validation process much simpler. In turn, each Block needs to only reference the one immediately prior to create a valid Link. Every Block is Linked together by this validation process in what is called the Blockchain.
Essentially what Bitcoin mining does is creating and verifying these links.
At the end of each Block the Bitcoin network creates a 256 bit encryption based on all transactions in the block. So, if anyone ever tries to change a record in a completed block this encryption would become invalid as it wouldn't solve for this altered record. Once this encryption is created the Bitcoin miners get to work trying to solve the Block encryption.
As 256 bit encryption is extremely secure it takes a lot of time and a lot of computing power to crack it and come up with the solution. Rather than trying to decipher the encryption it's easier to simply guess the solution. Basically the Bitcoin network is saying “I'm thinking of a number between 1 and 180 Quintillion" and Bitcoin miners are all competing against each other to try and guess the correct number. Each mining computer is connected to the Bitcoin network and continuously sends random numbers to the Block until it's solved. The rate at which random numbers are sent is called a Hashrate, the greater the Hashrate the more guesses per second a computer is making. The more powerful the computer the more guesses it can make. So to mine Bitcoin someone needs a powerful computer and enough energy to have it constantly guessing random numbers all day long. This is what makes it expensive, however its also what makes Bitcoin so valuable. The harder it is to mine the more it costs to buy already mined Bitcoin.
Whenever a Block is solved new Bitcoin is created and awarded to the miner who solved the Block. In the beginning each Block generated 50 new Bitcoin. However, after about four years that rate was cut in half to 25 Bitcoin per Block. It's hard coded into the Bitcoin network to keep cutting this rate in half roughly every 4 years until the very last Bitcoin is mined. This means that mining Bitcoin gets significantly harder every four years which translates into Bitcoin prices spiking every four years.