NOT MUCH MORE THAN A KILOMETER
The main problem with living deep underground is the geothermal gradient. It simply gets warmer the deeper you get, at a gradient of roughly 25°C for every kilometer of depth. This fact is used to create geothermal energy. Given that the average global surface temperature is 15°C, then even at 1 km (40°C), refrigeration is needed, and the deeper you go, the more refrigeration is required. Since refrigeration requires energy, it generates excess heat that must be channeled away. This will not be easy when the surrounding rock is hot. You could pipe cool air down from the surface, and then pipe the excess heat up, but this also gets more difficult the deeper you go - and it could contribute to global warming.
It is difficult to set a hard limit, as you can add insulation and increase refrigeration the deeper you go, but it gets increasingly impractical. More importantly:
THERE IS PLENTY OF SPACE ABOVE GROUND
Though it may seem that the world is changing into one huge urban landscape, that is in fact not the case. Only 3% of the Earth's land surface is currently urban, and a lot of this is lightly populated villages and suburban areas.
Tokyo has a population density of a bit over 6,000 people per square kilometer. Turning the Earth's entire land surface (510 million square km) into megacities of this population density will make room for about 3 trillion people. Food will be a problem, even though this leaves the oceans free of population - but the same is true if you put people underground. And you could feasibly leave the most fertile half of the land free for agriculture if you double the population density.