Happiness is a function of the prevailing tax rate, and the level of the city's tavern. The more taxed the populus, the less happy it is, while the more drunk the populus is the happier it is.
Happiness% = 100 - tax rate + tavern level
Impact on Population
The current population is a function of the population limit and the population's happiness. The happier the population is, the higher their occupancy rate in the provided cottages.
Current Population = Maximum Population * Happiness%
This is where your population will eventually settle to, but the process does take time. As the value changes you will see your population size trend up and down, until it eventually settles at this limit.
Changing Happiness into Gold (or vice versa)
Inside the castle, happiness can be turned into gold or vice versa. To temporarily increase happiness by 10 points, you give your population a tax refund of 10 pieces of gold per person. To increase gold, you tax your population by 10 pieces of gold per person, but happiness drops temporarily by 20 points. These temporary changes in happiness will slowly return to their expected values over time. A 20 point decrease in happiness takes 2 hours to recover back to the normal level. So this is a case where money CAN buy you happiness :-)