The way Hardware wallets achieve maximum security is by saving your private key and signing your Bitcoin transactions offline so someone who tries to "hack" your wallet remotely can not do it.
Most Hardware wallets also use a second screen / device to verify actions on your wallet such as signing transactions. In this way, if a hacker gains control over your computer, he still can not be dangerous as it requires access to the physical devices connected to your computer as well.