Bitcoin's difficulty is simply a measure of how difficult it is mine a block. The current difficulty number represents the number of hashes required to mine a single block.
A Bitcoin hash is deterministic with pseudorandom result, this means that everyone can calculate the target on their own and reach the same target. Hashing to a target difficulty is stochastic (randomly determined).
The difficulty is designed to maintain the rate of coin issuance and block confirmation times as the network grows or contracts.
Difficulty adjusts every 2,016 blocks (~2 weeks). A block sequence with the same difficulty is reffered to as a "difficulty epoch".
On the 2,016th block of the difficulty epoch the difficuly is recalculated. If blocks are mined faster than 10 minutes on average, difficulty increasees (target decreases). If blocks are mined slower, difficulty decreases (target increases).
The simple forumula for calculating the difficulty level is as follows:
Difficulty = Difficulty Target / Current Target
Difficulty Target is the highest possible target to be reached with a block hash.
Current Target is the hexadecimal difficulty derived from the 256 bit number in a block header.
Difficulty is the aproximate number of hashes required to mine a single block. The current difficulty is 27.5 trillion (T)
Bitcoin maintains its block time to be around 10 minutes with its difficulty adjustment algorthim. So why not 1 minute? Or one hour?
Because Satoshi never explained why block times need to average 10 minutes, we can only assume why this was chosen.
One explanation is that 10 minutes is a sufficient amount of time for nodes to propagate blocks to all other nodes in a peer to peer fashion.
After a Bitcoin block is mined, it takes time for other miners in the network to find out about it, and until then, the miners are actually competing against this new block instead of adding to it.
If someone mines another new block based on the old blockchain state, the network can only accept one of the two, and all the work that went into the other block gets wasted.
For example, if it takes miners 1 minute on average to learn about new blocks and new blocks come every 10 minutes, then the overall network is wasting about 10% of its work. Lengthening the time between blocks reduces this waste.
Each 2016-block interval is known as a difficulty epoch. With an average block time of 10 minutes, this averages to a two week period. At the beginning of every epoch the Bitcoin network recalculates the difficulty.
The Bitcoin network does this by measuring the time it took to the find the last 2,016 blocks and compares it to the expected time of 20,160 minutes (2,016 * desired 10-minute block time)
This ratio results in the difficulty moving up or down.
BUG! Due to a longstanding bug in the Bitcoin source code, the time spent mining the first block in each difficulty epoch actually has no effect on the next difficulty calculation. Even if this block somehow took an entire year to mine, it would not cause the next difficulty to drop, believe it or not!
The calculations on this site take this bug into account to help produce the most accurate difficulty estimate possible. For more information on this bug, please refer to this section of Andreas Antonopoulos's book, Mastering Bitcoin.
Fun fact! Even if all the worlds energy, resources, and computers were directed to mining bitcoin, the difficulty adjustment would readjust and keep block times 10 minutes on average. This preserves Bitcoin’s unique supply schedule and supply limit of 21 million coins, a level that will only be reached in the year 2140.