Candide by Voltaire is a novel written in response to an Enlightenment philosophy of the day, and by his use of satire, Voltaire clearly believes it is ridiculous. A philosopher named Gottfried Wilhelm von Leibnitz averred that the world can be nothing short of perfect because God created it and God is perfect. Everything that Candide and his tutor Pangloss believe and endure makes a mockery of this belief.
We meet Pangloss, instructor of "metaphysico-theologico-cosmolo-nigology," at the beginning of the novella, and his optimistic philosophy says this:
there cannot possibly be an effect without a cause and that in this best of all possible worlds the baron’s castle was the most beautiful of all castles and his wife the best of all possible baronesses. —It is clear, said he, that things cannot be otherwise than they are, for since everything is made to serve an end, everything necessarily serves the best end. Observe: noses were made to support spectacles, hence we have spectacles. Legs, as anyone can plainly see, were made to be breeched, and so we have breeches.... Consequently, those who say everything is well are uttering mere stupidities; they should say everything is for the best.
One of the misguided beliefs of Enlightenment thinkers concerned cause and effect, and here Voltaire mocks them. Obviously noses are not the cause of spectacles, nor are legs the cause of pants. More importantly, it is foolish to believe that everything that happens always happen for the best--as anyone who has lived more than a few years can attest.
Pangloss has a "mania for insisting that everything is all right when everything is going wrong," and Candide learns that from him. After he is forced to leave his love, Cunegonde, Candide inadvertently joins the army, nearly gets executed, gets a bucket of human excrement thrown on his head because of his religious beliefs, discovers that Pangloss has syphilis, has people around him die or get in serious trouble with some regularity, is shipwrecked with Pangloss, is nearly executed, gains and then loses wealth, has to buy Cunegonde's freedom...and the this is only a brief summary.
As all of this is happening to him and his loved ones, Candide clings optimistically to the theory Pangloss taught him; thus, all of these things, since they happened in this best of all worlds, are good things. Believing the beatings, the sicknesses, the losses, the trouble are all perfect things simply because they exist in a world created by a perfect God is beyond optimistic--it is delusional. Voltaire uses these extreme examples, such as Candide having to choose between running a gauntlet and be whipped thirty-six times or receive twelve shots to the head (he chose the whipping, of course), to point out the fallacy of this skewed, illogical, and overly optimistic philosophy.
By the end of the novella, Candide is finally, it seems, ready to reject Pangloss's philosophy. Pangloss says:
"There is a concatenation of events in this best of all possible worlds: for if you had not been kicked out of a magnificent castle for love of Miss Cunégonde: if you had not been put into the Inquisition: if you had not walked over America: if you had not stabbéd the Baron: if you had not lost all your sheep from the fine country of El Dorado: you would not be here eating preserved citrons and pistachio-nuts."
Candide dismisses all of that philosophical talk and says:
"All that is very well," answered Candide, "but let us cultivate our garden."