One part of the answer is quite straightforward: The optimal temperature would be higher than today.
It may look like it would be a problem to define such a thing like the optimal temperature. There are many different regions, and the global climate which is optimal for one region would be very problematic for another one. There would be winners as well as losers. How to define it in a fair way? This seems already impossible.
And, moreover, it seem already problematic to define an average temperature. A simple average which counts every piece of the surface of the Earth in an equal way? There are regions which are not important at all for humanity, why would one even care about them? This objection is easily answered: In fact, it does not matter how we define it, because what we really care about is how it changes. Change is relative, and a modification of the rule how to compute the average would not change much about the differences between the temperatures. So, we can use here whatever we like, and counting all areas, relevant as well as irrelevant, on equal foot is fine.
The question how to define which climate is optimal also has a sufficiently straightforward answer: This would be the climate where the greatest number of human beings could live on Earth.
All we would have to do to fix this number is to fix the human technology. Indeed, better technology could icrease the number of people who could survive on Earth in essential ways. Probably even such a change would not change the relative values. Why would one think that for one level of technology where would be another optimal temperature than for another? It is more plausible that the better temperature would remain better even if the technology improves. It would be, of course, imaginable that not only the number of people able to survive on Earth changes, but even the temperature which would be optimal, but it is not really plausible, and we would not even know the direction of such a change.
Moreover, we have not much base for guesses what will change with future technologies. So, there is a very simple choice: We simpy answer the question assuming that the technology is the one we have today. This can be easily computed, because we know what we have today, moreover, it gives a pessimistic, minimal number, given that technology usually improves, and that such an improvement will also increase the number of people who can survive on Earth.
But what about exhausting resources? Here, the answer is also quite straightforward: What matters is what is sustainable.
So, let's summarize:
What about the costs of adaptation to that optimal temperature? We have explicitly excluded them in our definition, despite the fact that they may be possibly large, especially if the climate change will be fast.
But it makes sense to consider them separately. It is quite important to know if some particular costs are costs of adaptation to new conditions which in the long run are better than those today, or if those new conditions are worse. If they would be worse, it would make sense to think about preventing the climate change, for example by applying the emergency stopgap proposed here. But to do this would be unreasonable if the new conditions are, in the long run, better than the actual ones.
That means, the property of the definition that it does not take into account the costs of adaptation is not a bug, but a tool. It is important to know this optimal temperature because it also defines the optimal reaction.
Once we have defined what means "the optimal temperature", we have to find it.
At a first look, this seems to be an extremely complex, if not an unsolvable problem. There are so many things which change if the temperature changes. It is so complicate to find out what would be the result of these changes, and, moreover, all these predictions depend on the speed of the change.
But in our definition of the optimal temperature we have already essentially simplified the question. Namely, we don't have to care about transition costs at all. Then, all what matters is how many human beings can survive. Thus, we do not have to care about the survival of other species to answer this question. All problems related with the survival of various species will be part of the transition problems.
Given these simplifications, we have already a simple base for predictions. What we would need, first of all, would be the distribution of various climate zones on the land. Such a stable distribution of climate zones on the land is what actual climate models already compute. Once we have computed, for a given temperature, such a distribution of climate zones, all what remains to do is to use the information we have about the maximal number of people who could survive with actual technology in all the particular climate zones, and then to apply this function to compute the number of people who could survive on Earth.
In principle, the same scheme works for the oceans too, except that we have probably much less knowledge about what would be the optimal outcome, even with actual technologies, given that what is actually done is a global overfishing which is clearly not optimal. It may be hard to find out which ocean temperature is optimal in a situation where what we do now is non-optimal in a very obvious way.
Whatever, to estimate the number of people able to survive on Earth at a given temperature is something which can be done in a reasonable way, and there would not be that much disagreement about the results.
The most important qualitative question is if the optimal temperature is higher or lower than the actual one.
But let's see what the straightforward expectation of a shift of climate zones will predict. There is a very large amount of land in Canada and Russia which is essentially unusable for normal agriculture simply because it is too cold. These regions can be actually used only as forests for wood production. A warming would allow to use them for agriculture. In the North of Russia and Canada, there are are also large regions where it is too cold even for wood, which results in a tundra. In these regions, wood could growth after a warming, so that they could be used for forestry.
There is no reason to expect a comparable loss of regions where it becomes too hot for agriculture.
Let's not forget the other key ingredient of the climate - precipitation. Higher temperature means also higher evaporation of water. More evaporation means also more transport of \(H_2O\) in clouds from the oceans to the land, and, in the average, more precipitation.
More rainfall is, in general, positive for agriculture. This will remain obviously true for a quite large increase of precipitation, given that there are a lot of regions on Earth which are too arid for agriculture, but none where we have too much rain for doing agriculture.
What is often mentioned in discussions about global warming is that this leads also to more irregularity, volatility of the rain, with resulting storms and floodings. This is a quite plausible side effect, but such irregularities hardly prevent a successful use of the land for agriculture. In particular, in many cases problems with floodings can be minimized or even avoided by dams.
There may be situations where dams cannot help. The classical example where this was impossible was Ancient Egypt. All the land which could be used for agriculture was located in the Nile valley. And the whole Nile valley was completely flooded every year. Despite this regular flooding of all the agricultural area, Ancient Egypt was a powerful and impressive civilization which build impressive pyramids. So, floodings become a big problem only if they are unexpected. This may play some role during a transition period, but hardly decreases the overall result once people are prepared and have developed an appropriate corresponding infrastructure.
There are, first of all, sufficient memories of the time of the Little Ice Age to conclude that this time was quite harmful for Europe, and catastrophic for those living in Greenland and Iceland. Of course, this does not tell that much - it may have been only a local phenomenon, possibly restricted to the Northern Hemisphere. There is little known about the influence on other parts of the world.
What is known about times where the temperature was higher seems much more positive. So, here I have found some :
Thus, we have even two independent reasons to expect that a modest increase in temperature, which will be accompanied by a rise in precipitation, will be positive:
Therefore, it seems quite obvious that with increased temperature the possible amount of food which could be produced by agriculture will increase, giving food to more people. This is, according to our criterion, sufficient to consider a higher temperature as positive.
What would be the optimal temperature for humankind is another question. This question should be left to future research.