Market considerations: putting in swearing, cruelty and other nasty behavior will lessen one's market and create a negative buzz; word gets around. I doubt many readers seek out or crave such elements, or would refuse to buy a book lacking them. But the converse is assuredly true, namely book bannings, whether ad hoc via parent networks or commentary on 1-star reviews, or (temporarily) by library or school officials, hurt sales and reputations.
That said, Catcher in the Rye is still controversial almost 65 years after its first publication. In that ongoing case, freedom of speech/the press became degraded and meaningless because students were denied the right to not buy/listen to/read the book, and parents their right to control what their children were exposed to. Another creeping victory for the Leviathan State. But I remember quite clearly that we students only wanted to titter over the naughty words, forget about the rest of Salinger's storytelling. Have I read it even once since being forced to in high school? Nope. Is that really what a writer needs? To join the potty-pen club?