What stops a wallet from stealing bitcoins? I'm not particularly knowledgeable on the topic of cryptocurrencies so it's possible that I've missed something obvious, but I still wonder what it is that stops a wallet from stealing from you. Wallets contain your private keys and they obviously have to use them to be able to send coin. So what stops a given wallet from stealing bitcoin from a user in the background without the user's knowledge?
What stops malware from being malicious?
Nothing
What can you do to ensure that the wallet you are using is a secure way to access your bitcoin?
Use an open source bitcoin wallet, download from the original source and verify authenticity before use. If you understand code, review and build it yourself.
Obviously, if a person creates a wallet to steal bitcoin from users, they would not share its source code to be reviewed by everyone. Although, even that is possible and I have seen a few altcoin smart contracts that were created to steal user funds. Since not everyone is able to understand code and review it, in that case a few people ended up being victims before word got around.