I heard that 90% of people in the middle ages were peasant farmers.
But what was the rough percentage of greek farmers to city dwellers in ancient greece, or in roman times?
If different from the middle ages, what were the reasons for this?
90% is probably on the high side, as while fewer than a tenth were generally urban, the rural population always contained a substantial minority making a living from trade, services or crafts, often supplying the agricultural sector. 70-80% is probably a more reliable proportion specifically agricultural, at least in the later Middle Ages: earlier it may have reached 80%. It's slightly complicated in terms of status in that many of the non-tillers would have occupied a similar rank to their agricultural neighbours, differing rather in the labour or goods that they supplied - so they may be counted among the peasant population despite their non-farm livelihood.
Proportions probably weren't very dissimilar in the Roman Empire. We may think of it as exceptionally highly urbanised when we consider Rome, Alexandria or other regional metropolises. But it was also a big polity with upwards of 50 million inhabitants. An urban share of 10-15% still leaves 70% or so likely to be engaged in agriculture, maybe a tenth of them slave. Italy was more urban (perhaps 25-30%), more slave (a fifth or more) and less agricultural (a half to three-fifths), but most of the provinces remained more solidly peasant.
Greece is altogether different to the medieval norm. Hansen has estimated the urban population in the wider Greek world at upwards of 40%, which may be an overestimate, corresponding as it does to modern Greece's 1920s level (in the probably more comparable 1890s it was nearer a quarter). But there's no question that ancient Greece was more urban than its successor. That suggests perhaps only around a half or so engaged in agriculture. How was such a high ratio of townspeople to farmers sustained? As with later Italy, the answer has to be food imports, given that most of Greece isn't among the most fertile of lands. Comparison with the 1880s when net grain imports resumed suggests that perhaps a million Greeks relied on such shipments in the 5th century BC.