Large areas in the lands of the world are completely uninhabited and uninhabitable. But, unlike international waters which aren't part of any country, those uninhabitable land areas are claimed by one (or more) country(ies).
Examples (non-exhaustive list):
The Sahara desert is traverse by several well defined international borders, and the entirety of the desert is claimed by at least one country. On the other hand, when seeing a map of Ottoman Empire at its greatest, we can clearly see that they did not claim areas deep into the Sahara desert.
Some parts of the Himalayas mountains, which are too remote from inhabited village to be really considered part of a country.
Areas close to the artic pole in e.g. Canada, Alaska and Russia, which are too cold to be inhabitable.
Places wild down the Amazonian forest which are extremely remote to any human civilization, yet the whole Amazonian forest is traversed by well defined borders and claimed by countries.
So why and when did the international law allow countries to "annex" those inhabited areas at some point? Especially back when the technology didn't allow anyone to physically reach those area?