I know you have strong feelings here, but here's my take on his casting.
He represents in the movie the establishment. Something part of everyone's daily life. Safety, stability, family. Someone everyone knows. For that reason, casting perhaps one of the most famous living actors in that role cements for the audience that instant connection...you know him...you like him...you respect him. He's safe. And then at the end....bang. Complete disruption, completely unexpected...
Feel free to bash his acting, he was a little stiff for sure but that's how he acts in almost every movie.
I think he was there for what he represented to society...not only society of those in the movie, but folks watching the movie. Insta-connection....and if there was one person in that movie most people subconsciously would consider "safe", it'd be him. To make Joker's "coming out" scene be one that involves breaking that trust, that connection, that feeling of safety...is why he was there. Again, dislike his acting style all you want and I won't really disagree...but it was effective having him there, having that unspoken trust, unspoken safety shattered, really added (in my opinion, and I'm sure you'd disagree) to that moment and punctuated Joker's utter disdain for society, for establishment, for the status quo.