NEW YORK — It's a happy accident that one of the best recent contemporary art exhibitions, the Hans Haacke retrospective at the New Museum, coincided with one of the more dispiriting art stunts of late, the now infamous banana taped to the wall that became the talk of Art Basel Miami earlier this month.

Haacke’s work has always been smart and challenging, in ways that inspire productive dialogue with other artists, critics and audiences. The banana, a conceptual piece called “Comedian” by artist Maurizio Cattelan (who has made much more interesting work than this), inspired a lot of talk, too, but most of it was chatter.

And that’s the difference between good and bad art. Good art creates discourse; bad art, such as the banana, is like a presidential tweet, an effort to seize the conversation and dominate it for a brief but viral moment, making everyone wish they could talk about something else.

The New Museum exhibition is the first American retrospective of Haacke’s work since 1986, when the same institution hosted an important survey of the German artist’s career. The current show has, deservedly, received ecstatic reviews since it opened in late October. It includes careful and thoughtful installations of the artist’s kinetic and environmental works made in the 1960s and early 1970s, trenchant satires on corporate greed and insatiability, installation pieces that document political and economic connections between art and neoliberal instability, and the New York premiere of his 2014 “Gift Horse,” a giant skeletal horse created for the empty plinth in London’s Trafalgar Square. Spread over four floors, “Hans Haacke: All Connected” is an exhilarating tribute to the artist’s consistency of vision, his integrity and ideals and his resistance to the trivial, distracting and dissipating forces of the contemporary art world.

Haacke gravitated to making art while studying to be an art teacher in postwar Germany, and his work has always had a didactic brilliance. Early pieces invented ways to capture the instability of complex systems: the way water forms waves or the motion of bubbles in a tube, how condensation forms and drips in a transparent box, or the billowing currents of a diaphanous fabric floating on a column of air. There was a deceptive simplicity to these early pieces that was different from the engagement with static, perfect forms pursued by artists now thought of as minimalist. Haacke’s aesthetic was similar to the pedagogical distillation of a good physics or chemistry professor, animating ideas through carefully chosen experiments that clarified their essence.

Haacke built his life in art rather like a scientist, too, working outward from small-scale revelatory insights to encompass ideas of process and theoretical structure. He came of age with artists who were asking basic questions about the larger systems of art, its definition, circulation and the economy that supported it. Who was paying for museums and exhibitions? How do paintings move around in the world, acquiring economic value and social prestige? Who was visiting museums and why did they come?

In 1971, he created one of his most influential and contentious works, “Shapolsky et al. Manhattan Real Estate Holdings, a Real-Time Social System as of May 1, 1971.” It was a research project focused on Harry Shapolsky, one of the city’s most egregious slumlords. The work included photographs and printed text, documenting the complex web of companies through which Shapolsky did business.

The Shapolsky piece was supposed to appear in a one-man show at the Guggenheim, along with other Haacke pieces that questioned the nexus of museums, wealth and social status, but the museum canceled the exhibition (and fired its curator) after Haacke refused to remove the work. Thomas Messer, the museum’s director, said the censorship was necessary to “fend off an alien substance that had entered the art museum organism.”

That language was telling, with its assumption that the museum is a coherent organism with its own bodily needs, and the suggestion that art that threatened its economic survival was like an infection. But in the long run, Messer’s censorship of the show backfired: Nothing could have secured the future of an art practice now commonly called institutional critique better than the ham-handed response of the Guggenheim.

The New Museum exhibition not only includes an installation of the 142 black-and-white photographs and printed cards that form the visual bulk of the Shapolsky project, it also presents an even more visually engaging work, “Gallery-Goers’ Residence Profile, Part 2, 1970.” The Gallery-Goers’ project also used photographs, in this case to document who was visiting a prominent New York gallery that specialized in avant-garde art. But in this case, the photographs are clustered to show which city neighborhoods had sent the most people to the gallery, creating a visual analogue to the rhythms of wealth and bohemian ambition in New York during the late 1960s and early 1970s.

Both works feature functional, straight-on documentary images of buildings in New York, and their objectivity and lack of glamour makes them feel like architectural mug shots. At some level, much of the best of Haacke’s work feels like an exercise in taking metaphorical mug shots. His work arrests and indicts, putting people who move and shake things, political leaders and corporate titans, under a microscope.

But the viewer, too, is wrapped up in all of this because Haacke’s work is on view in a museum, which a social construct. Work that explores the close relationship between irresponsible corporations and money-hungry museums forces the visitor to think like someone implicated in a crime: Did I see that show supported by that rapacious oil company? Have I benefited from the trickle-down largesse of people who profited from apartheid, or colonialism or environmental destruction?

“Gift Horse,” the giant skeletal equine fashioned for London, distills Haacke’s invitation to ethical self-consciousness into a haunting visual gesture. It is monumental in scale, and thus initiates our reflexive tendency to submit or show respect to things that are powerful or commanding. But it also includes a continuously scrolling stock exchange ticker on a bow tied on its front thigh bone. Wealth, it seems, has flayed it alive, reduced it to bare bones. This is the future of capitalism and its hollow promise of prosperity on planet Earth, a charnel house of our own making.

There is a tendency to think of the art world as a thing apart, a rarefied cosmos of intellectual games, gestures and ripostes that exists independently of the so-called real world. Catellan’s duct-taped bananas are thought of as family affairs, inside jokes, mental games that function a bit like secret handshakes or curated shibboleths. “Gift Horse” suggests otherwise, connecting basic social habits like the veneration of public icons and material consumption to the same market forces that made the art world, and the banana, possible. Only a massive reapportioning of the world’s wealth to a tiny faction of people since the 1980s could have made any of this possible.

“All Connected” is a dangerous subtitle for the show, but an evocative one. At one level it suggests a stupid, conspiratorial way of thinking, the kind of idiocy that exercises anti-Semites and Q-Anon types, and a lot of mediocre conceptual and political artists. But things are connected, if you study them carefully, dispassionately and with rigorous skepticism. Haacke has done that for decades and his connections always hold up.

Hans Haacke: All Connected Through Jan. 26 at the New Museum in New York