In Germany there are currently between 200 and 2000 climate activists in the Lützerath hamlet fighting the forced sale of the hamlet to a mining company. They are primarily on/around the property of farmer Eckardt Heukamp who objected to selling his farm. Here is the wikipedia article and here is a BBC article.
In general the forced sale of land is driven by the ideas of Eminent Domain, which is the forced sale of property to the government for public use. The justification for the existence of Eminent Domain laws always heavily relies on the use of the land to be for the public. This case however implies that a company (the farmer) is forced to sell its land to another private company (RWE), so that the latter company can profit off of the resources in the land owned by the farmer against the wishes of the farmer.
The only case I can think of where Eminent Domain is used somewhat commonly for sales to a private company is for the purchase of land for railways, but this is - as far as I am aware - justified by the positive externalities of train networks, so it's basically a form of 'subsidy'. Such a reasoning does not seem to apply to a mining company.
So my question is basically: What is the reasoning behind laws allowing entire villages to be sold to private mining companies? Does the state get some 'maximum energy prices' or something similar in return to justify this as a 'public use', or is there a completely different justification?
(Btw, I am not particularly interested in the specifics of German law, and more so in the general justifications for 'laws like this', so answers for different jurisdictions are welcome as well)