OS hardening is a necessary process since hackers can gain access through unsecured ports. All of this process reduces the attack surface area and eliminates a large number of tactics an attacker could utilize.
OS Hardening is basically to keep the environment up to date. So, any vulnerability present in the version can be mitigated by security patch released by vendor and any logical flow bypass can be prevented by applying appropriate policies.
Hardening of the Operating System is the process of configuring an OS securely, updating it regularly, creating rules and policies to govern the system in a secure manner, and removing unnecessary applications and services. This is performed to minimize the exposure to threats and to mitigate possible risk.