These tools emulate a local KMS server on your own PC. When you run them, your operating system is tricked into believing it is part of a legitimate corporate network, thereby granting you an activated status.
This is completely legal and safe.