Fundamentally, it boils down to land, food production, and energy production. The current distribution of our 32.4 billion acres of land looks something like this:
Over a third of the world is still covered in forest. Only a ninth is actively farmed. Our buildings, roads, and other human features only physically occupy a bit over one percent. Over 40% is covered with grasslands, scrub, or meadows of various quality, much of which is used for grazing. The remaining 16% is mountains, rocks, and ice. This land currently supports our population of 7.1 billion, but most certainly not in a sustainable manner. Can we do better?
Let's assume a world of 25 billion people. This article finds that crops based around a balanced, various and healthy vegetarian diet yield a combined yield of 2.4 million calories per acre using mostly organic techniques. Assuming 3000 calories per day per person (2000-2500 actually consumed, plus waste and spoilage), an increase in cropland from 11% to 35% (11.4 billion acres) would be required. Is this possible? Yes it is. In fact, only a fraction of the world's farmable land is actually farmed. This source indicates that there are actually 10.3 billion arable acres available, close to our 25 billion person target of 11.4 billion. It is fair to assume that we can grow, raise, or harvest 10% of our crops on non-arable land. For example, greenhouses for raising vegetables, or sustainably raised meat. Most of this new farm land would be found in the currently forested parts of the world, with smaller amounts coming from the grasslands, scrublands, pastures and meadows.
As for meat, we could no longer consume as we currently do, as we spend several calories of grain to make one calorie of meat. Obviously, in the 25 billion person world, every calorie counts. However, if we were to use half of the grasslands, scrublands, meadows and pastures for grazing, we could raise about half a billion head of grass-fed cattle (or equivalent weights of sheep or other animals), enough to provide each person with about 35 lbs of meat per year. Additionally, with diligent attention and management, we probably can harvest about ten pounds of fish per person each year. This would represent only about 80% of current production, which is clearly unsustainable.
What about energy? Assuming an entirely solar photovoltaic system, energy production averages 5-20 W/m2 depending on location. To provide everyone with 200 GJ per year (above the average Japanese, below the average American), and assuming we can average 15 W/m2 by placing most of our solar panels in the sunny deserts, it would require 2.6 billion acres to provide power to all 25 billion people. This is about 8% of the world's surface, the majority of which would come from the "other" wasteland category, scrub lands, or even piggy-backing on rooftops on developed land.
How about wood, cotton, and other fibers? For wood, the average American consume 1900 kg per person per year. Assuming we can cut that down to 700 kg of bamboo and 500 kg of hardwood, at 44000 kg and 6600 kg of wood/acre/year respectively, we would have to intensively tree farm about 2.3 billion acres, or 7% of the world's surface. Likewise, at current American cotton consumption of 3.3 kg per year and production rates of 700 kg per acre, about 100 million acres would need to be diverted to cotton production. Another 100 million would be required for other fiber or industrial crops. This amounts to 0.6% of the world's surface, which we can include in the cropland category.
So what does the distribution of land use look like after we make these changes?
Obviously, there are some things not to like. Half of the world's forest cover would be gone, and nearly half of what remains would be intensively managed. Somewhere between a quarter and a half of the other natural land types would be consumed as well, and half of the remaining lands potentially useful for grazing would be used as such. Less than a third of the world would be unused. However, that is more than you might think: only around 10-15% of the earth's land is currently protected as parks, national forests, or the like, so if this unused third was distributed intelligently, there would be plenty of natural areas accessible to people for recreation and at least a bare minimum for wildlife to continue to exist. This is obviously sub-optimal from this respect, but there is no way to achieve a high human population that doesn't demand sacrifices.
So yes, there is nothing stopping us from having a dramatically higher population than we currently do, or are ever projected to have, other than our own stupidity. Unfortunately, that is a vast mountain to climb.