The maximum number of people in a settlement is 10 plus 1 per each Charisma point the player has. The more people a settlement has, the more effective the settlement is, since more resources can be assigned and production increases. However, this also means more resources are needed to keep the settlement's happiness up.
Some settlements start with a number of inhabitants already, while others have to be attracted by creating a settlement that meets all of settler's needs (all resources in the green) and erecting a recruitment beacon. The player receives five settlers for free at Sanctuary Hills upon completion of When Freedom Calls (although only four of them can be assigned tasks: Jun Long, Mama Murphy, Sturges, and Marcy).
If there is lack of people in one settlement and an abundance in another, some settlers can be sent to a settlement that needs them through use of the supply line mechanic of the Local Leader perk.