A glorious case of ''miscasting'' has resulted in a peculiarly fascinating drama. Mr. Halpern and Mr. Johnson (HBO, Sunday, Aug. 28, 8-9 p.m., Wednesday, Aug. 31, and several additional times during the month, check local listings) starring Laurence Olivier and Jackie Gleason in the title roles, might never have seen the electronic light of day at all, if not for the affluence of pay-cable's Home Box Office. HBO is pouring some of its huge reservoir of subscription money - 11 million subscribers at up to $20 a month each - into interesting television projects cast with big-name stars. (Next month, for example, HBO is presenting Elizabeth Taylor and Carol Burnett in ''Between Friends,'' an original drama.)
Produced by Edie and Ely Landau at HTV Studios in Bristol, England, ''Halpern and Johnson'' by Lionel Goldstein is basically a long dialogue between two mature men who for four decades maintained two very different relationships with Halpern's now-deceased wife, Florence.
Lord Olivier plays the Jewish-English spouse of Florence, and Mr. Gleason plays her distinguished upper-class platonic friend.
The two meet, recount the impact of Florence on their lives, resent each other's roles, then recognize that their mutual links to this woman must inevitably make them friends as well.
Lord Olivier, who affects a lower-class Cockney accent intertwined with Yiddish inflections, mugs his way through the encounter. If he whines too much, perhaps that is his interpretation of the character. If there is just a bit too much of the flamboyance of the ''greatest living actor of our time'' in this rather modest role, it is still a delight to watch our generation's quintessential actor at work.
The same delight is present when one watches Gleason at work - although it is difficult to view this ''Honeymooner'' seriously as a man of discretion and distinction. Unlike Olivier, he plays it rather straight, when the role could stand for some superficial affectations.
But all through my viewing of the show, I kept thinking: Wouldn't it be interesting to see this little drama with the actors reversing their roles?
No matter. Obviously director Alvin Rakoff felt his offbeat casting was enough to carry the play, because he makes no attempt to aid the actors with any directorial twists or tricks.
''Mr. Halpern and Mr. Johnson'' is a straightforward tour-de-force, just a bit heavy on the tour (feat) and light on the force (strength). Consider it a privilege to see two master craftsmen at work.