This saying comes from John Stuart Mill. In it, he is trying to explain what it really means to be happy. He is responding to the idea that a pig is happier than a person or that a fool is happier than a philosopher because “ignorance is bliss.”
According to Mill, there is a difference between being contented and being truly happy. A fool (or even a pig) can be content. Pigs and fools do not have or do not use their higher faculties. Therefore, they don’t think about things and are content so long as their immediate needs are taken care of. To Mill, this is not true happiness. To Mill, true happiness consists of using your higher faculties. A truly happy person is one who understands the world through use of higher faculties such as reason. People who think may be discontented at times because they understand how imperfect the world is. However, they are capable of being truly happy because it is better to understand the world and still be happy than it is to be content because you are ignorant.
People, and particularly people who think, are happier because they have a better understanding of the world and because they are operating on a higher level than pigs and people who do not think. This is what Mill is contending in this quote.