A public blockchain has no administrator deciding which version of history is correct. Proof of work substitutes a cost that makes competing versions impractical to sustain.
The problem is agreement without an authority
Thousands of independent computers hold copies of a shared ledger, and any of them can propose the next set of transactions.
Without a rule for choosing among proposals, the network would fragment into inconsistent histories, and the same funds could be recorded as spent twice.
Proof of work resolves this by attaching a measurable cost to the act of proposing, so proposals are scarce rather than free.
Hashing turns electricity into a lottery ticket
Miners repeatedly run candidate blocks through a cryptographic hash function, searching for an output below a target value set by the network.
There is no method faster than trying, so the chance of finding a valid block is proportional to how much computation a miner performs.
Verification is trivial by comparison: any node can check a proposed block's hash instantly, which is what makes the asymmetry useful.
Difficulty adjusts to keep the pace steady
As more computing power joins the network, blocks would be found faster, so the protocol periodically raises the target's difficulty.
If computing power leaves, difficulty falls, which keeps the average interval between blocks roughly constant regardless of participation.
That adjustment is why block timing stays stable over years while the total computation devoted to the network changes enormously.
Rewriting history means redoing the work
Each block references the previous one, so altering an old block invalidates every block after it.
An attacker would have to redo all that work while the honest network continues extending the current chain, requiring more computing power than the rest combined.
Nodes follow the chain with the most accumulated work, which is why a transaction becomes progressively harder to reverse as blocks are added after it.
The cost is the security and the criticism
The energy consumed is not incidental to the design; it is the resource that makes attacks expensive and therefore unattractive.
That same consumption is the basis of the environmental objection to proof of work, and it motivated alternative consensus designs that substitute staked capital for computation.
Those alternatives change what is at risk for a dishonest participant rather than removing the requirement that something be at risk at all.