The section of the book that your quote comes from is a wonderful exchange between Montag and Beatty. About a paragraph or two after Beatty says the "custodian" quote, he says the following:
"Ask yourself, what do we want in this country, above all? People want to be happy, isn't that right? Haven't you heard it all your life? I want to be happy, people say. Well, aren't they? Don't we keep them moving, don't we give them fun? That's all we live for, isn't it? For pleasure, for titillation? And you must admit our culture provides plenty of these."
The pursuit of pleasure is called hedonism. Beatty is explaining to Montag that he believes firemen ensure that the members of the society are capable of being hedonists. Beatty explains that books encourage free and creative thinking, and he sees that as dangerous. He compares it to a "loaded gun." A book could encourage divergent thinking. Worse, a book might cause a member of society to learn something and feel bad or sad about it. That would run counter to the pursuit of pleasure.
"Coloured people don't like Little Black Sambo. Burn it. White people don't feel good about Uncle Tom's Cabin. Burn it. Someone's written a book on tobacco and cancer of the lungs? The cigarette people are weeping? Burn the book.... Forget them. Burn them all, burn everything. Fire is bright and fire is clean."
To Beatty, fire is a cleaning agent. Custodians are people that typically wield cleaning agents while doing their job. Firemen are the new custodians because they keep society clean by not allowing any dirty ideas to come into the minds of potential readers. The more books that the firemen burn, the cleaner and happier the mindless population is.
Beatty believes that books make people unhappy and and are a source of confusion to them. By burning the books, firemen are insuring that the people enjoy peace of mind because the cause of their unhappiness has been destroyed. Ironically, Beatty's words belie the fact that suicide is so common in Montag's world, that when Montag's wife attempts to kill herself, the emergency response it to send only technicians to save her life. Obviously, it is not books that cause unhappiness, but the entire hollow nature of their society.
Ideas are dangerous. They are upsetting for the individual, and they can change or even threaten society. Ideas are found in their most concentrated form in books, and therefore, firemen preserve society's peace of mind. How? They burn books, the source of these disturbing ideas.