A hard fork in a blockchain refers to a deviation from the original protocol or previous version of a blockchain. The most famous crypto hard fork resulted in the creation of Bitcoin Cash.
In mid-2017, when issues of scalability first arose, there was a lack of consensus in the community as to an appropriate solution. Some members of the community supported increasing the block size while others were ardently opposed to tampering with the original protocol. Proponents of the increased block size prepared a code change and the resulting hard fork resulted in the continuation of two separate Bitcoin Blockchains, the original Bitcoin and the new Bitcoin Cash with the increased block size. In this case, most of the nodes chose to stick with the original Bitcoin but some broke off creating a new coin.
Although Bitcoin Cash will always go down in infamy it is not the only hard fork, nor is it the only type. Blockchain forks serve a variety of different purposes. In some cases, they are used to fix security issues or add new functionality. They can even be used to reverse fraudulent transactions.
Ethereum also experienced a hard fork in its infancy. The original DAO (Decentralized Autonomous Organization) was hacked and 3.6 million dollars' worth of Ether was stolen. The community was left with a tough decision, implement a hard fork to undo the damage or continue and allow the perpetrator to run off with everyone's investment. In this case, most of the community was in favor of the proposed hard fork and what is now known as Ethereum is the result of that hard fork. Ethereum Classic is the original blockchain.
Beyond these two infamous hard forks, there are a variety of instances where updates or changes have been made either routinely or otherwise to various blockchains for innumerable reasons. Some examples include the implementation of SegWit for Bitcoin and Constantinople for Ethereum. There is some debate in the community as to whether these are actual ‘hard forks’. They are sometimes referred to as ‘soft forks’.