The Challenges Of Decentralization
Creating an entirely digital currency with no central authority overseeing the transaction records presented several significant challenges that would need to be overcome. One significant characteristic of anything digital is that unlimited perfect copies can be made of it. How could a decentralized and functional currency be created without this fact being exploited? How do you stop someone from creating a copy of an incoming transaction that gave them money, altering a few details, and doubling their income? Or how do you make sure there's no way for someone to spend the same money twice? Or buy something then alter the transaction record afterward so that they have the money back, along with whatever it is they purchased? Bitcoin solves these issues with several very innovative measures.
Validation By Peers
Bitcoin embraces the "perfect digital copy" principle, and uses it as an advantage by distributing a complete copy of the transaction ledger to every full node on the network. When a transaction takes place, it is checked by nearby nodes on the network to make sure that it is in fact a legitimate Bitcoin transaction, and verify that the Bitcoins being spent haven't already been spent somewhere else. This makes it extremely difficult to forge a transaction, because if the other copies of the ledger don't have a record of the transaction that came before it, it will be rejected by the network.
This technique of cross-referencing transactions with other copies of the database is a great first step, but in order for it to work, steps have to be taken to make sure the transaction record remains consistent across all the nodes on the network. This is where the miners come in. Mining is often thought of in terms of the miner running a machine in the hopes of earning Bitcoins, But it's important to understand what's going on under the surface- because it helps to explain why a Bitcoin is able to have any value and function as a currency.
Keeping Things Consistent
Miners are the "bookkeepers" of the Bitcoin ledger, enlisted to confirm the validity of the most recent transactions and organize them into the "blocks" of transactions that are added to the permanent distributed record every ten minutes. In order to ensure that there would be an adequate number of users willing to commit their time and computing power to maintaining Bitcoin's ledger- and in order to ensure that there would be a desire to maintain it- an incentive was given to participate. Whenever a new block is added to the chain, whoever adds it is rewarded with new Bitcoins. These rewards given to miners are the only way Bitcoins are created. They are generated and sent to the miner in a special transaction that inspired the name of a wallet: This transaction is called a coinbase. All valid Bitcoins have a coinbase at the beginning of their transaction history.
Regulating The Bitcoin Supply
With new people able to join the Bitcoin bookkeeping effort from anywhere- even today, with the increased difficulty, anyone with the right hardware can do it- and with the reward incentive creating greater interest in joining the effort, steps had to be taken to make sure that multiple blocks of transactions weren't being added to the record at the same time- otherwise it wouldn't be possible to keep the ledger consistent throughout the network. And a Bitcoin wouldn't be able to hold much value if anyone was able to easily grab some by validating a block.
Reward After Proof of Work
With Bitcoin these issues are solved by requiring a math problem, known as a "cryptographic hash", to be solved before a new block can be broadcast to the network. There is a very low number with a lot of zeroes at the beginning that must be found, known as a "nonce"- which is short for "number used only once". The difficulty of the equation that must be solved is dynamic, and continually adjusts itself depending on how powerful the current mining hardware on the network is. This was put in place so that finding the nonce, and adding a new block to the chain, would always take about ten minutes.
(This use of cryptography to regulate the recording of transactions and distribution of new Bitcoins is why bitcoin is often reffered to as a "crypto" currency).
The most recent transactions on the Bitcoin network are simultaneously organized into blocks by miners everywhere. But only one of them will add their block to the chain. They are in a race to find the right nonce that will solve the equation, and whoever does this first will be rewarded with new Bitcoins. After a miner has found the required nonce, the block is broadcast to the network and added to all of the full-node copies of Bitcoin's distributed ledger. The transactions within it are given their first confirmation, and they are now recorded- permanently- on the blockchain.