If bitcoin mining still works after the latest halving, how much can someone invest in the mining of the bitcoin and how much bitcoin is it likely to generate before the mining plan expires?
Mining will continue until Bitcoin exists. Once the miners mine all the Bitcoin, they will still run miners because they will still get the transaction fees. I believe Bitcoin will be worth a million by then, and the transaction fees will be enough to cover the expenses of running miners. I am not a miner, but I believe a lot of them will stop mining since the block reward will be half every four years or so.
The mining farms continue to mine regardless of whether they are in profit or loss. Because they know that Bitcoin will pump in the future and they will make a profit. That is how miners recover the loss they did when they continued to mine while it was not profitable.