There’s a number of factors involved:
- Geographic: access to a good natural harbor or a river that offers good access to the interior, being at a ford or mountain pass, being at a crossroads.
- Political: a royal court or the court of a powerful lord, or an actual sitting judicial body.
- Religious: a prominent cathedral, church, or monestary, the location of an important shrine or reliquary or some other association with an important saint, being on the route of a pilgrimage.
- Economic: having a charter to hold a market, nearby miines, a concentration of a particular industry like metalworking or textiles, etc.