What are the factors that drive the cost of bitcoin mining? Bitcoin mining is vital for maintaining the integrity of the blockchain ledger. If the cost of bitcoin mining gets too high and enough miners give up, the ledger will not be maintained properly and many transactions will fail. To understand this risk, I would like to understand the factors that drive the cost of bitcoin mining.
The main factors making mining attractive are :


The coin's value 
The mining difficulty
The price of electricity
The price of the required hardware
The mining fees


The higher the coin's value the higher the miner is rewarded. The less difficult it is, will likely result in more coins. Some countries have almost free electricity which makes mining much cheaper. There's also the initial investment, which is the required hardware for mining. Mining fees also help increase mining's profitability.

When mining a coin becomes attractive more miners will come which would result in more CPU power which gets corrected by a higher difficulty. If suddenly half the mining power was to disappear, we would see a difficulty adjustment.