These days you can only get the rewards from the coinbase transaction if you find an extremely small hash, using several exahashes/s of hashpower from mining rigs, and no less. This costs a lot of money, because it all pulls megawatts of power, not to mention the enormous costs of buying all those miners in the first place.
So, a bitcoin mining operation will be at a loss initially but may become a net positive in the future if successful. Most aren't though, and that's what deters hackers (who would just be legitimately mining for themselves instead of trying to backdoor thousands of Bitcoin Core installations, which is infeasible) from mining and coinbase transaction rewards.