As you can read here it is not possible to recover the root password on ESXi. Generally if you forget root password... you have to reinstall ESXi host. But the question is: is it always necessary? Fortunately NO!

If your ESXi hosts are added to vCenter you can use Host Profiles (available in Enterprise + license) to change the root password on ESXi host!

How to reset root password: