Your post is somewhat misleading on two parts.
1) You ask (in context)"would a union defend...." this is misleading insofar as it being a question. Unions don't have that choice. Until a grievance process has been exhausted, the union is the advocate. Just like lawyers MUST defend their clients a union must defend its members. The result for not performing this task/doing so in a sub standard manner usually results in a DFR lawsuit against the union.
2) you infer that unions keep people who should be fired from being fired. This is just another tired union cliche. I was in aviation for 22+ years. 18+ of that was in a union position at UAL, and I can assure you that all the pencil whippers at United that UAL could prove did so, were NOT saved by the union. Additionally, what I saw over the years at UAL was sloppy investigative work/preparation by the company. I know this will probably start a whole stream of responses but in my experience those that "should've been fired" weren't saved by what you refer to as "layers of of contractual legalese" but by ineptitude on the companies part. Case in point. I was involved with a case to terminate a mechanic who had one of the worst attendance problems I've ever seen, or heard about. This individual had received progressively intense discipline (all perfectly legal) from the company. If the company had continued along its already established course of his attendance problem, the union could've done nothing more than help him pack his tools. However, what happened in this case is an overzealous up-and-coming young supervisor just wanted to be rid of this individual(understandable)went and trumped up charges, the individual was walked off the property and held out of service for over 1 year as his termination hearings/appeals were heard. Now if the company had just stuck to his attendance issue, the mechanic was done, in this case though they used trumped up charges that the union(rather easily) proved false. So after a year out, the individual was returned to work with full back pay.
This is the type of story that many people tend to spin into unions stopping people from being fired who should be. For those of you nodding I'd caution you, be careful in that thinking. A thief may indeed be a criminal, but does that make it okay to charge him with murder unjustly??