A fork generally is a change to a project’s source code. Bitcoin is an open-sourced project, meaning that anyone can access, download, or alter the source code without permission.
A hard fork specifically is a consensus change that is not backwards compatible. Backwards incompatibility occurs when a previously invalid behavior is made valid. In order to maintain consensus across a hard fork, all nodes are required to upgrade. Otherwise, old nodes will reject transactions or blocks as invalid under the old rules, while upgraded nodes will accept them as valid. For this reason, hard forks are avoided at all costs in Bitcoin.