Farms are indeed dangerous but they are essential for max income.
Basically your income is proportional to the square root of your population. So the higher the population the higher your income although at a square root relationship you have to quadruple your population before you double your income. Your income is also directly proportional to your income. Double taxes and you double income.
Population is also related to approval. The more people you have the less happy they are. Approval is also related to taxes, again where the higher the taxes the less happy people are. Finally approval relates back to population in that the lower the approval the lower the population growth. Population, taxes, approval and pop growth are all balled up in a complex relationship that is even more strongly negative than the square root relationship between population and income.
The thing is that the relationship between approval and pop growth is a step function and so there are really only three points at which it's desirable to operate.
If a planet's population is low it's losing money and you really want to grow it's pop as fast as possible so you want it to be at 100% approval at all times. Essentially you need to lower taxes to keep all your low pop planets growing so that your income grows as well. Once a planet's pop is up to a "reasonable" amount (and this amount changes over the course of the game) then all you need to do is to keep that planets approval above 40% because at 40% and below you actually start losing population. An intermediate point is the 75% level. Basically at 100% approval you get a bonus to pop growth, at 75% and above you get "normal" pop growth, at 41% to 74% you get no growth at all and at 40% and below people start dying.
The bottom line is always keep all planets above 40% approval and keep planets that you want to become more profitable at 100% approval. Also keep any planet that you still want the pop to grow on above 74% approval.
To counteract low approval you have morale buildings and morale techs and wonders and morale mining resources as well as your innate racial morale ability which tend to keep you happier for a given level of population which then allows you to have higher taxes and therefore more income than someone that has a lower morale ability. The problem is that the benefit of each of these items is diminished by the population of the planet itself. So while a VRC might start out giving a 40% approval bonus when the population is low it ends up giving (I think) only a 16% bonus when your poulation is at 20B.
The bottom line is that Morale = Money however the relationship is very complex and extremely negative and if you go just a little past where you're able to control it you can get really screwed.
Basically you don't want to even think about adding a farm and going past your default max population until you've researched the morale branch of the tech tree and earned the morale bonuses available as well as building most of the "wonders" that give a morale bonus. At that point it's OK to add a single advanced farm to each planet except civilization capitals. Towards the end of the game when you pretty much have control of the galaxy (and therefore control of most of the galaxy's morale mining resources) you can add a 2nd advanced farm at which point you'll also have to add 2 Virtual Reality Centers as well to keep your approval reasonable. I basically do this for only non civilization capitals that have are PQ11 or greater. Planets less than PQ11 I just leave with a single advanced farm and no VRC's.
That's pretty much it.
If you want the real details about income, population, approval and morale take a look at the following wiki articles, but the method I've described above is a pretty good "working" method for controlling your approval while getting the highest income possible.
https://www.galciv.wikia.com/wiki/Economy
https://www.galciv.wikia.com/wiki/Tax
https://www.galciv.wikia.com/wiki/Population
https://www.galciv.wikia.com/wiki/Approval
BTW never under any circumstances build a farm on a 300% food bonus tile. The 300% food bonus tile is the most useless and most potentially damaging tile there is. It's fine to use a 100% food bonus tile on a planet that you will eventually want a 2nd farm but that's it. 100% approval bonus tiles are also useful but like I said I usually don't use morale buildings at all until I go to the 2nd farm and try to control the planet at 20B.