It is theoretically possible.
Blockchain.com estimates that the hashrate of bitcoin is 13,000,000,000,000,000,000 hashes/second. Any one of those hashes could be "The lucky one" that earns 12.5BTC. Your CPU can get on the order of 2,000,000 hashes/second (plus or minus). This means your computer has roughly a 1 in 65,000,000,000,000 chance of being the lucky one that mines the block. The remaining 64,999,999,999,999 times, it's someone else (typically someone with a huge ASIC rig). If you mined for a billion years, you could actually expect to mine a block (using "expect" as in the statistical "expectation" of a random variable).
A bitcoin block is mined roughly every 10 minutes. At $20k per bitcoin (extrapolating a bit, based on its current excitement), that's $250k generated every 10 minutes. You have a 1 in 65,000,000,000,000 chance of being that one. Accordingly, your expected earnings (due to that random luck chance of getting the right chance) is .0000003846 cents/10minutes, or .0000023 cents/hr. If you are spending more on electricity than that, you're wasting your money.
3It is possible that the very first hash it tries could be successful, and then it "earns" 12.5 BTC for a few seconds of work. However, the odds of that happening are roughly larger than the age of the universe. – abelenky – 2017-12-16T00:49:51.903
1
@abelenky: "the odds of that happening are roughly larger than the age of the universe". Ever heard of dimensional analysis?
– Eric Duminil – 2017-12-16T10:01:58.910