How difficulty increases to get the lucky hash in blockchain?

The Bitcoin algorithm is written to aim for 2,016 blocks being mined roughly every 2 weeks (which works out to ~1 block every 10 minutes on average). After every 2,016 blocks, the network will adjust the difficulty based on how long those previous 2,016 blocks took to mine: if it took longer than 2 weeks, the difficulty is decreased; if it took less than 2 weeks, the difficulty is increased.

For the exact calculations and more information: