I too remember being shocked by the Joker shooting Bob the Goon near the climax of Batman. The reason he does it is apparently to show that the Joker is in the process of completely losing it. Up to that point, he has been clearly insane and pointlessly, murderously violent. However, he takes some care that he does not easily get caught while executing these schemes. (For example, the way he pollutes the chemicals in various cosmetics to make them poisonous is too complicated for the police to figure out, although Batman, knowing of the Joker's connection to Axis Chemicals, does figure out what is going on.)
Killing Bob shows that the Joker is completely losing control. His homicidal madness is becoming so wild that he just lashes out in rage at the nearest target when Batman breaks up his most recent plan (using the Batwing to take out the poison gas balloons). The Joker is no longer capable of making decision according to even a modicum of self interest. He has become a totally animalistic monster.
His casual murder of Bob shows the audience that the reasonably careful Napier is completely gone, and the crazy, uncontrollable Joker is all that is left. It also serves another plot purpose, since the betrayal and killing of Bob ensures that the Joker has no goons left, so that the final confrontation with Batman in the cathedral can be a one-on-one face-off.