For a fully developed medieval country, the population density will range from 12 people per square kilometers, if the region is at constant war, has gloomy weather or inhospitable terrain, to 48 per square kilometers, for region with rich soil, favorable seasons, etc.

1For some context, in the XIV century, in Germany, the density was about 24 people per sqkm, in the same period, Sicily had the lowest population density of the southern Italy, with 19,4 people per sqkm. Tuscany, on the other hand, had at least three times as such, if not four times the population density of Sicily, between 60 and 80 people per sqkm.
French in the XIV century had a density just upwards of 38 people per sqkm, the British Isles, had a population density of 15 people per sqkm, mostly squashed in the souther parts of the archipelago.

Randomly generating population densities

To roll randomly population density, something like this might work:
Roll , the multiplier can be reduced down to to represent a gradient of going from high developed areas, to wilder, less-developed lands, or to represent countries depopulated by invasion, plague, or other calamities.
If you want to generate randomly varied regions, you can replace the multiplier with a roll of a .

Town and Cities

  • Villages (Villaggi): from 20 to 1000 people, typically around 50-300 people. Most kingdoms will have thousands of them. These are agrarian communities, within the safe areas of civilization, providing food and land-stability to the realms.
  • Towns (Cittadine): from 1000 to 8000 people, typically around 2500 people. These tends to have walls only if they’re politically important and/or frequently threatened.
  • Cities (Città): from 8000 to 12000 people. Large kingdoms usually have only a few cities with a population this large. Centers of scholarly pursuits (Universities) tend to be in cities of this size.
  • Big Cities (Grandi città e/o Capitali): from 12000 to 100000+ people. Some historical examples are London, Paris, Genoa, Venice and Moscow.

Large population centers are usually the result of traffic: coastlines, navigable rivers, and overland trade-routes form a criss-crossing patterns of arteries and towns and cities grow along these lines. The larger are these arteries, the larger the cities are going to be. Villages are scattered densely trough the country between the larger settlements.

Population Spread

This is a simple algorithm for calculating the population spread for a kingdom.

  • Determine the population of the largest city in the kingdom. This can be estimated by where is and is a random roll of (average: 15).
  • The second-ranking city will be from 20-80% of the size of the largest. You can roll this by rolling (average 50%).
  • The remaining city will be from 10% to 40% smaller than the previous one (, average 25%); continue listing cities for as long as the results maintain a city-scaled population (8000+).
  • The number of towns can be estimated by (average result is 9).

The remaining population live in villages, smaller settlements or isolated dwellings.

The ration of towns to cities given above presumes the existence of a thriving mercantile community. You can adjust the number of towns upward by 50% or more for a world on the verge of Renaissance, or adjust it sharply downward for a pre-Crusades type of world.
Historically, the number of town charters in many European countries multiplied nearly by 10 from the XI-XIII centuries as economic shifts reshaped the agrariann scheme into something more robustly mercantile.

Agriculture

A square kilometer of cultivated land, will support around 70 people, taking into account blights, rats, droughts, and theft. If aided by magic, this number could go up.

Other useful metrics

1 squared kilometers equals to 100 hectares.
1 hectares of cultivated lands supports 0.7 people.
1 person needs 1.4 hectares of cultivated land to survive.

However, for some region like medieval Italy, 70 people per square kilometers is really achievable only in very fertile region and in prosperous periods. A more sound number could be around 35-50 people per square kilometer, in normal conditions.

An average family need around:

ParameterEstimated values
Family Composition~5 people (2 adults, 3 children)
Cereal need of the family5 kg a day = ~18 quintals per year
Necessary land14 hectares per family
Actually possessed and cultivated land< 10 hectares in average (≈50% of what they needed)

Castles

While this is very world-oriented, you can safely take that there is a functioning castle for every 50,000 people. 75% of these castles will be near civilized areas of the kingdom, the rest will be isolated or near borders.

Merchants and Services

Each type of business has a Support Value (SV), meaning the number of people it takes to support a single business of that sort. You can adjust the SV table by a percentage equal to . Those with the lowest SVs represent professions which attract the most prized artisans and experts to the city.

Other things. There will be one noble household per 200 population or so, one place of worship every 400 if there’s a clear “dominant” faith, but will be much more common if there are dozens of faiths with none dominant.
A well kept medieval city will have 1 law officer for every 150 citizens.
There will be a university for every 25 million people.
Livestock population, whole, will be roughly 2.2 times the human population, where
will be fowl (chickens, geese, ducks, etc.) the rest will be dairy cows, goats, and meat animals like pig.

BusinessSVBusinessSV
Shoemakers150Butchers1,200
Furriers250Fishmongers1,200
Maidservants250Beer-Sellers1,400
Tailors250Buckle Makers1,400
Barbers350Plasterers1,400
Jewelers400Spice Merchants1,400
Taverns/Restaurants400Blacksmiths1,500
Old-Clothes400Painters1,500
Pastrycooks500Doctors*1,700
Masons500Roofers1,800
Carpenters550Locksmiths1,900
Weavers600Bathers1,900
Chandlers700Ropemakers1,900
Mercers700Inns2,000
Coopers700Tanners2,000
Bakers800Copyists2,000
Watercarriers850Sculptors2,000
Scabbardmakers850Rugmakers2,000
Wine-Sellers900Harness-Makers2,000
Hatmakers950Bleachers2,100
Saddlers1,000Hay Merchants2,300
Chicken Butchers1,000Cutlers2,300
Pursemakers1,100Glovemakers2,400
Woodsellers2,400Woodcarvers2,400
Magic-Shops2,800Booksellers6,300
Bookbinders3,000Illuminators3,900
*These are licensed doctors. Total doctor SV is 350.

Footnotes

  1. Source: Reti Medievali - Università degli Studi di Napoli Federico II.