The purpose of a nonce in blockchain is to add an element of randomness to the process of mining blocks. Miners need to find a hash value that is below a certain target value to successfully mine a block. The nonce is a number that miners can adjust in order to try different combinations and find a hash that meets the target criteria. This non-deterministic element helps ensure that the process of mining remains competitive and decentralized.