Forks are changes in the rules according to which blockchain is formed. Forks can be used to fix the existing wrongs, upgrade and improve the existing code, or create a new chain with new coins. For example, Bitcoin's hard fork, Bitcoin Cash, happened on August the 1st 2017 when developers couldn’t come to a consensus on block size. If a part of the community agrees with one set of rules and the other with the other set, two chains that adopt different rules divide and run alongside each other. Both chains are functional.
How Forks happen
There are two reasons why forks are formed.
One, forks are born as a result of changes in the rules according to which miners and nodes run blockchain and validate transactions. Rules may include the size of the rewards for found blocks, block size, etc.
Because cryptocurrency is still very much a developing concept, updates, fixes, and new solutions regularly come out. Because blockchain is a decentralized system, in order for the rules to be changed, there needs to be a consensus from the community. Miners may not agree on what is the best (or most profitable) solution. Developers (see above) can decide to split and start working in different directions.
If a blockchain is to get hard-forked, the number of a block is specified. The code is designed using the new set of rules. When the block goes live, users can choose to go with the original version or fork off and build blocks on the forked version. These two versions of blockchain will become incompatible.
Probably the most pleasant part of the forking process is the end result, as users get the amount of coins on the original chain plus the same amount of coins on the forked version. However, the price of the new coins is still subject to demand, which means this is not necessarily a bonus.
Two, forks are what happens when, as a result of miners’ efforts, two blocks’ hash gets found with an insubstantial time in-between. Because the hash gets sent to the rest of the network for verification from both miners, a percentage of the users will validate one result, and a percentage of the users will validate the other. The two parts of the chain will then be faced with the dilemma: as miners build the network, next blocks will be based on the different hash, which means that the network will be split in two.
For example, Bitcoin’s P2SH is a soft fork. Users that haven’t installed upgrades will be able to communicate with and send coins to those who did, while upgraded users will have more functionality. Soft forks mean that the network will follow the old rules as well as the new, and they are backward-compatible in the sense that the upgraded nodes still see the non-upgraded nodes as valid.
There is no division in the network and there are no new coins. Soft forks need 51% user adoption, unlike hard forks wherein everyone needs to upgrade. SegWit saw Bitcoin code altered (or, depending on the perspective, improved) without conflicting with the old rules. Soft forks allow upgrading blockchain (which is the cornerstone of its capability to function) without destroying cooperation between chains.
The division into Bitcoin/Bitcoin Cash and Ethereum/Ethereum Classic is an example of a hard fork, which is different from the other type (soft fork) in that it is not backwardly compatible. For example, Litecoin reduced the block’s creation size to 2,5 minutes and upgraded coin emission to 84 000 000 rather than 21 000 000 proposed by Satoshi Nakamoto to begin with.
Hard forks normally are a software update which renders the old rules obsolete and unusable. The old nodes that follow the old rules will consider the new nodes invalid. In order to switch to the new chain, the nodes must upgrade.
Likely the most quoted example of a hard fork that divides the team (a contentious hard fork) is the case of Bitcoin and Bitcoin Cash, as a result of which two different lines of a network exist.
Bitcoin Cash users believed the size of the blocks should be greater, so the chain was created that involved 8 Megabyte blocks rather than 1 Megabyte blocks that Bitcoin used (despite the fact that the idea of higher blocks was built into the original whitepaper by Satoshi Nakamoto). In this case scenario, the nodes from the new chain do not interact with the nodes from the old chain.
Hard forks can also be planned, like Bitcoin Gold, which was designed by the team to counter double-spending attacks. This is an announced event, of which the community is aware and supportive of, and that includes extending and improving the functionality. The new chain depends on a lot of hash power to survive, and if it does, the likes of Ethereum Classics survive and continue functioning.