There are are a number of critics as well as ordinary viewers, of whom I am one, who think the answer is the 6 part BBC program of 1986 The Singing Detective written by Dennis Potter. In the US it was never shown by any network, broadcast or cable, because Potter (who had the control) refused to allow the program to be edited in any way by any broadcaster -- and some of the content was 'advanced' by US standards of acceptability 20+ years ago.
On an ad hoc basis a few PBS stations in the US did show it and it was shown in Canada by TVO, the Ontario educational network. However it remains largely unseen by North American viewers although it ranks as Potter's masterpiece -- and he was a prolific writer of drama mainly for television although his work was uneven. In the US and Canada his best known work is likely "Pennies From Heaven".
A warning for those who choose to stake out the position I have posited above: do not allow the discussion to be sidetracked by any reference to the insipid 2003 Hollywood movie version of Potter's work also entitled "The Singing Detective" starring Robert Downey Jr and Adrien Brody. In quality, length and content it cannot stand even in the smallest fragment of the shadow cast by the BBC original.
Potter was a brilliant if eccentric writer born in 1935 in the Forest of Dean in Gloucestershire where both his father and grandfather were miners. He suffered all his life from a serious condition called psoriatic arthropathy, a form of arthritic joint disease associated with chronic skin scaling. Potter died in 1994. The lead character in The Singing Detective, set in mid-1980s England, not only suffers from this medical condition but because of it spends the entire drama in a hospital ward. The condition, or more specifically its symptoms and manifestations, are a key element in the drama.
So why do some people regard this program as a masterpiece? After all it is, to say the very least, multi-layered and the plot is not easy to follow. It is fair to say that on first viewing it is likely to be a couple of hours into the 6 hour series before the first time viewer will get any real sense of how the layers overlap.
I will attempt a summary but one I admit does little justice to the complexity of Potter's drama:
Philip Marlow, a minor English novelist of Raymond Chandler-style noir detective stories, suffers from a crippling disease and is back in hospital with another severe attack. He hallucinates and complains while he is treated and eventually recovers to the extent that he is able to leave hospital. He (i.e.,the character Marlow) had written some years before a novel called "The Singing Detective" which he now rewrites in his mind with himself as the lead character, a singing detective -- hence the title. Woven into this surreal experience are his memories from childhood in the Forest of Dean during World War II as well as an overlapping fantasy of spies and criminals ca 1945. Throughout the drama one hears original recordings of popular songs from the era, usually appearing to be sung (in Marlow's fevered brain) by characters in his imagined drama.
This summary makes The Singing Detective sound bizarre and it is but it works so well it deserves its standing as a 20th century masterwork for television. The cast is superb: Michael Gambon as Marlow and as the 'Singing Detective' in his own novel, Patrick Malahide in 3 roles and Janet Suzman as Marlow's wife Nicola. They are supported by a superb cast of English character actors.
The program can best be understood and enjoyed over several viewings. Many video rental places will not have it in stock although they likely will have the more recent Hollywood movie version. The BBC has made it available for purchase on DVD and it can be ordered through DVD sales outlet including Amazon.
The Singing Detective is well worth viewing more than twenty years on and its impact, as too often is the case with a program one enjoys and revisits years later, does not seem to fade.