Night Court would not work well without a live audience. I think things like sight gags work better with an audience laughing (though Modern Family did a good job of it without one). But I think a lot of people think that because it doesn't have a laughtrack/live audience, it's not a "smart" comedy.
As a veteran of the genre, I can say there are basically two reasons to have a live audience.
The first is the belief by producers that a live audience inspires the cast to do better, especially in season 4 or 5 when the stars' characters are well established and they are pretty much phoning it in.
The second and more important reason is it gives the writers, who are all on set during audience shows, the opportunity to see which jokes land and which ones fall flat. After a scene is done, they huddle with producers (sometimes the writers
are the producers) and note which (if any) jokes didn't land and they try to come up with new punchlines for the scene that they think are funnier. Then the scene is reshot with old+fresh material, and the laughtrack is revved up a bit since the audience will have already heard most of the jokes. Shows shot with an audience are shot in a linear fashion, beginning to end, so it makes sense to the audience. And sometimes, one or two scenes are preshot during rehearsal the day before for whatever reason, and that scene is played back to the audience in sequence with the live stuff. No rewriting there, obviously.
Normally, the laughtrack is piped into the studio at mild levels to encourage the audience to laugh, and if there isn't enough live laughter is also used in editing to punch up the amount and volume of laughs.
Shows like Modern Family went a different way, selling themselves as a faux documentary/reality show with lots of shaky handheld camera shots and the obligatory 'confessionals' directly to camera by the characters. It was shot single camera style (I think - or maybe two cameras) and often out of sequence which means the show is built in editing and a live audience would just be confused by what they are seeing.
And then there are shows like M.A.S.H. which are 'comedies' with serious undertones, usually shot on location, where people die regularly (including cast members). No audience for those. The show had a laugh track initially, but Alan Alda put a stop to it.