It's not required, obviously. But art as its commonly understood (and specifically protected in many countries' constitutions) functions as one of the mechanisms of a "civil society", much like journalism, unions, religions etc.
In that sphere, i. e. politics (broadly), there are no crazy new inventions that make everyone happy. Science can find a cure for AIDS and nobody will complain. But politics is to some degree a zero-sum game, where a finite amount of "power" can only redistributed.
Almost any change will therefore have opponents: the sexual revolution frustrated catholics, #metoo unearthed buried guilt etc.
"Ugliness" really doesn't play into it. Every city has places far uglier than any piece of publicly displayed art I can think of. More often, it's the actual idea that freaks people out: The holy Mother Maria spanking the infant Jesus[0] is not too bad on the eye, but it's a really strange idea[0] (From the 1920, by the way–shock value isn't a new idea).
The Nazis hated Picasso not (just) for his Guernica, but because they abhorred uncertainty, subjectivity, and doubt. That's why they rejected his (and most other) abstract art. It's also why they really didn't like relativity and quantum physics: it's possible that they missed their chance to get the atom bomb first because they had aesthetic objections to this "strange new relativism".
[0]: https://i.pinimg.com/originals/2e/8b/96/2e8b9610aca3535a8d6b...