They are as secure as your personal compute habits, which for most people are not great. The reason they are considered to be relatively "insecure" is that they are effectively a plain text file stored on your computer.
Think of file system wallets like a text file with your all your username/passwords in it. Would you store valuable information and login info in a plain text file on your computer? I hope not (and if you do, you should reconsider that!)
If your computer has some malicious code/virus/npm package that is running on it, then in would be trivially for the malicious code to scan the common locations that the keypair json file is stored and send it back to the attacker.
Browser based wallets a bit more secure since your private key is encrypted at rest. Meaning, when you enter your browser wallet password, it uses that password to decrypt the file system wallet and load it into memory. So if some malicious code was on your computer, scanning for keypair files in the browser extension data, they would get an encrypted file.
They would then need to obtain your web wallet password (via brute forcing or social engineering) to access your wallet's private key. This is more difficult for an attacker, but still possible given enough time.
Which is why hardware wallets are the most secure. Since the private key never leaves the device. Instead, a transaction is sent to the hardware wallet device, the transaction is signed, and send back to the computer's operating system to handle the transport to the blockchain.
A POC of a malicious package could be interesting and fairly easy to write. This type of attack is referred to a "supply chain" attack. If a package/crate was compromised, then it could exfiltrate private keys on a system.