There are lots of older threads that discuss the relationship between population and happiness. A quick way to brush up on the situation is to look through the wiki.
https://www.galciv.wikia.com/wiki/Population
Basically, as population goes up, tax revenue goes up - assuming tax rate constant.
Also, as population goes up, morale goes down.
Also, as taxes go up, morale goes down.
And, as morale goes up, population growth rate goes up. Similarly, if morale is low enough, population decreases.
Farms raise the maximum population level. Planets with higher quality have morale bonuses - I think Quality 11 is the first to get such a bonus.
In any case, it is a trade off or balancing act, empire-wide but on a planet-by-planet basis. Additionally, a planet's Influence grows with population.
One last note, the Governor will automatically upgrade structures once new tech is gained unless you turn it off on any planet you want that not to occur. Hence, if you gain new farm tech (even if inadvertently by conquering or espionage), you will suddenly find all your farms (and population caps) increased. Thus, the balance you may have taken pains to engineer can be undone!