Mining is not a way to earn a yield; that's PoS and BTC is PoW. You use energy to earn BTC. Mining will always be profitable to some (as long as there is a non-zero block subsidy), thanks to the difficulty adjustment. There are multiple variables at play here and the system is designed to stay in an equilibrium. Halvings shake it up, but it finds a new equilibrium.