Proof of work (PoW) is a way to show that someone spent real resources, while anyone else can check it almost instantly. Bitcoin uses it to decide who may add the next block and to make the history expensive to rewrite.
The idea before Bitcoin
In 1997, Adam Back proposed Hashcash, a system that required email senders to do a small amount of computation per message to fight spam. Satoshi Nakamoto cited Hashcash in the Bitcoin white paper and used the same principle for a much bigger purpose.
How it works in Bitcoin
To create a block, a miner must find a block header whose SHA-256 hash is below a target number. Because hash outputs are unpredictable, the only way is trial and error. Finding a valid hash takes, on average, an enormous number of attempts. Checking it takes one. That asymmetry, hard to make but easy to verify, is the heart of PoW.
What it achieves
Fair selection. The chance of finding the next block is proportional to your share of total hash power. No permission or identity is needed.
Immutability. Each block's work stacks on top of the work in earlier blocks. To change an old transaction, an attacker would need to redo the work of that block and every later block, faster than the honest network. That is why more confirmations mean more safety.
Objective consensus. Nodes simply follow the valid chain with the most accumulated work. No vote is needed, which keeps consensus simple and hard to game.
Keeping the pace
The difficulty adjusts every 2,016 blocks so blocks keep arriving about every ten minutes, however much hardware joins.
Alternatives
Other blockchains use proof of stake, where validators lock up coins instead of spending energy. Bitcoin's developers and users have stayed with PoW because its security rests on external, physical cost instead of on the coins themselves.