Proof of work is a consensus algorithm that is used in Bitcoin and many other cryptocurrencies. Due to proof of work Bitcoin and other cryptocurrencies can be transferred peer-to-peer securely without the need to any third party. Before Bitcoin peer-to-peer money transfer was not possible.
Proof-of-work is needed to make the digital money work without a trusted third party or government. Proof-of-work solves the “double-spending problem,” which is trickier to solve without a leader in charge.
After choosing what all transactions should go in Block, a miner has to solve a cryptographic puzzle in order to attach the Block in Blockchain. Proof of work requires a computer to continuously generate Hashes until a Hash value is below the given Target or a certain number of leading zeros.
Block contains a Block Size, Block Header, Transactions Count, and Transactions. The miner can only change a Nonce Value inside a Blockheader in order to find a valid hash. Miner has to generate Trillions of Hashes per second to find a correct hash that starts with a certain amount of leading Zeros.
Once the miner is able to find the valid proof of work, he will broadcast the Block announcing to other miners that have found the solution. The rest of the miners in the network will validate the broadcasted Block and if everything is good they will accept the Block and start competing for the Next Block.