THE enduring popularity of Rab C Nesbitt is not simply down to the fact the character is funny. Screenwriter Ian Pattison’s Nesbitt is a complex, intelligent, self-destructive Govanite, a Socrates-in-a-string vest creation with a Taser mouth whose existential views on the complexities of society and human relations have caused the nation’s mouths to stretch wide with – occasionally appalled – laughter. At times Scottish bums would shift uncomfortably on the corduroy sofa of Presbyterian sensibility.

Yet, there’s another reason why we’ve remained Rab-connected for 30 years. We recognise this man. We’ve all known a Nesbitt, an intelligent creature whose goals have been thwarted by circumstance, perhaps by their Celtic heritage, their Scottishness.

But from where did the Pattison anti-hero emerge? A new Radio Scotland documentary explores the writer’s relationship with Govan, the shipyard area of Glasgow he grew up in during the 1950s and 1960s. Pattison’s schooldays, the programme reveals, saw him expect little more from life than to become a working automaton like practically every other man around him. The dream of becoming a writer wasn’t even on the horizon.

Today, however, Pattison reveals there was someone who gave an indication there could be fun in life, if you could find a way to laugh at its unfairness and absurdity. Pattison’s Uncle Bernie, like a west of Scotland Santa, left his nephew a sack-full of comedy presents which he was to open many years later.

“There are all sorts of influences that flutter through your head when writing but in the early days some would more than others,” says Pattison. “Bernie was a Govan man, innately, with all the attributes and flaws contained therein and I used to always enjoy his company. There was a crackle in the air when he was around, a witty edge, and you had to be on your game. He could see the comic possibilities in the otherwise mundane and he alerted you to the potential of the everyday. That certainly rubbed off on me.”

Uncle Bernie, who was married to his mother's sister, was around five feet eight. “Dangerously tall for Glasgow where the cloud line starts at five foot nine. He was known as 'Big Bernie', as much for his charisma as his stature. Wherever he was, that’s where the heat was. Always a twinkle, a misleading smile and the mild hint of anarchy.”

The writer adds, grinning: “Bernie even had his own glossary of words. He’d refer to his local pub, as The Beauty Parlour. As in ‘Magrit, that’s me away down the Beauty Parlour’ – I assume my auntie thought he must be having a demi-perm and a few pints of mascara.

“He was, as my mother described him admiringly, a ‘fighting Irishman’ although the unfortunate blemish was that he was actually born in Scotland, of Irish descent.’’

Bernie, like Rab, didn’t so much practise work-avoidance as work evasion. “I would have been about four, I think, when sitting on his knee one day I asked him what he did for a job. He said, ‘Son, I’m with the polis’, and there was laughter round the room. It transpired he would often be with the polis, usually after a spirited debate had spiralled out of control in the Beauty Parlour. ‘I don’t know what the Latin for ‘Time to pay please your honour’ is but if Bernie had a coat of arms that’s what would have be on it.”

Bernie wasn the victim, not of the glass ceiling, but a class ceiling, says Pattison. Though clearly intelligent, he had no peer group to spur him on. “He had gifts and had he been middle-class they might have been cultivated more assiduously, and he would have gone to university.”

Did he ever give his nephew advice? “He wasn’t in a great place to lead by example. But what Bernie represented was the lack of untapped potential in Govan. Thankfully, that culture is changing, which we talk about in the radio programme. Self-expression is an industry these days and people like Loki are becoming the articulate, complicated, voice of the working classes. In Bernie’s time, you would have been as well trying to take a 55 bus to the moon by way of Balornock and Jupiter than find yourself broadcast on Radio Scotland.”

Uncle Bernie’s take on life was to crystallise in Pattison’s mind in 1988 when Rab C Nesbitt first appeared in sitcom form. But before that euphoric moment, the writer’s journey was both challenging and representative of the times.

When he was 10, the family moved from collapsing Govan to a shiny new council house estate in Johnstone in Renfrewshire. It had a bathroom and everything. “Some politicians had a vision back then.”

Times were changing. “When I first went to secondary school the front pages of the papers would be full of Harolds, MacMillan and Wilson, you had to be a Harold to get into power – suddenly there were the Beatles and the Harolds looked immediately ancient. The world seemed transformed overnight.

“I’ve got a photo of myself and pals at the school dance," he adds, "and we had the slashed back hairstyles. Six months later we’ve all got Beatles haircuts. All things seemed possible.”

Pattison left school at 15, his talent for writing compositions of no practical use. He tried several jobs; he was a Post Office telegram boy, a warehouse labourer and an apprentice coppersmith. “Anybody less equipped to smith copper I’ve yet to find.”

In the summer of love, 1967, Pattison and a pal hitchhiked to London with little more than hope in their pockets. “We reckoned we’d meet John Lennon and he’d spot how bohemian we were and invite us to the Speakeasy Club. That’s how naïve we were. Instead, we ended up sleeping in doorways.” To get home to Glasgow, Pattison's record player was pawned. Back on Clydeside, he took on a series of jobs: a bus conductor, a waiter in Butlins holiday camp. “The staff had a great time, I can’t speak for the punters.”

A little older, in 1969, he took off to London again and moved into a flat in East Putney with his then girlfriend. He took on new jobs. “At one time I was working in the Houses of Parliament, sweeping the corridors of power. ("At least I stayed. Some of the Lords would turn up, sign the Attendance book and hop back into a taxi.")

“I loved London," he adds. "All the misfits went there. You’d meet all kinds of people with all kinds of influences. I’m still in touch with one or two.’’

A quirk of fate helped his self-belief. Pattison’s girlfriend had become friends with a woman in the same building. The pair discovered that the men in their lives were would-be writers and so engineered a meeting of the boyfriends.

“George, who lived downstairs, told me later that when his girlfriend suggested the meeting, he figured I would be a total tosser," laughs Pattison. "And he was probably right. But when we met we talked all night about writing, him giving me insight into the books I should read, the great novelists. This was absolutely electrifying to me. Mental windows were suddenly flying open.”

Pattison flirted with poetry, writing endlessly, whether Orton-esque or Pinter-inspired plays. His confidence growing, he sent one play to a London Theatre. “It was about people trying to get on in life, a Pinter parody, somewhat. I may be flattering myself but I felt it wasn’t so much rejected as ejected. 'We have now read your play. Thank you very much.'

Pattison’s class frustration (and anger) was reflected in his reply, written on cheap toilet paper. “Thank you for reading my play," it read. "I hope this will come in handy when you finally have the poker removed from your a***.”

He went through periods of frustration. “I was thinking, ‘Why am I doing this? If I want to be unhappy I can carry on doing the job I’m doing. I don’t need to send out for extra angst.’ My final deduction was this: ‘Writing is an itch; if you scratch it, it hurts. If you don’t scratch it, it hurts worse. Keep going.’’

Meanwhile, it was becoming too expensive to live in London on shop worker wages and Pattison moved to the north of England where he worked as a salesman while writing at nights.

Inspired by The Lower Depths, Maxim Gorky's 1902 play about a group of impoverished Russians, which he'd read while idling during his Houses of Parliament job, Pattison wrote a sitcom script called Doss, set in a hostel for down-and-outs, and sent it to BBC Scotland. It was filmed as a pilot, and though it didn’t make it to a series, at least his name was catching attention and he was suggested as a comedy sketch writer for Naked Radio.

“I was grateful for the chance and the experience but I really wanted to write my own show. I said to myself if I were still writing sketches in five years I would quit.”

Naked Radio was a pivotal series. It gave a platform to emerging writers such as Bob Black who wrote City Lights and Phil Differ (Only An Excuse?) “No-one was kicking the sacred cows of Scottish society up the a*** at that time.”

Pattison did. He wrote sketches such as The Bears, featuring the exploits of a generic Scottish family. Naked Radio evolved into BBC Scotland TV sketch show Naked Video, and Pattison was one of many contributors. But how to make a real impact?

Rab C Nesbitt, it transpires, was born out of the oddest of circumstances. “I was living in this maisonette apartment in the north of England with my then partner and it was New Year’s Eve,” Pattison recalls. “She was friendly with the people who lived downstairs and had invited them up for a drink. I wasn’t that keen to sit talking to them so I said to her, ‘Tell them I’m in Glasgow. Give them a quick drink and get them out.’ And when the doorbell rang I went upstairs to the loft, where I would sit and write.

“So in they came, but it soon became obvious they were all enjoying themselves. I could hear the laughter and the clinking of glasses. And I couldn’t say a word because I was in bloody Glasgow.”

Pattison was fuming, mostly at his own folly in banishing himself to a loft to bring in the New Year on his own. Five hours passed. He needed to let off steam. “I had notebooks up there so I decided to try and write some stuff for this new show, Naked Video. But ideas weren’t coming thick and fast, perhaps because the brief was not to be too parochial; this was for a network audience. I tried to write up this character who was a Liverpool councillor but the words were clunking to the floor because I wasn’t feeling it.”

And then, out of sheer frustration: “I just began to auto-write, in Glasgow parlance, to romp in the verbal clover. And out of it a character and a monologue emerged. Somehow it was liberating, the words had vitality. I remember thinking, ‘If this gets to Gregor Fisher it will work.’”

It did get to Gregor Fisher, Naked Video’s rising star. But Fisher thought the monologue featuring this Glasgow drunk to be as “funny as cancer", reckoning it was having a go at Scottish people.

“Colin Gilbert the producer persuaded Gregor to persist. His argument went along the lines of, ‘We’re paying you – now hurry up, the light’s going.’ Three takes later the penny dropped with Gregor. He began to realise there were actually layers to it.”

There were. Nesbitt had intelligence, an absurdist, quixotic take on life. The sketch show was broadcast in 1986 and Pattison’s drunk man howling at the moon was hugely well-received. He was encouraged to write another monologue about this “self-confessed scum. All I knew then was he had this head bandage – I was being symbolic, life was a permanent head wound – and Winfield (Woolworths’) trainers. I then put him out in the world, sent him to the Job Centre and watched him interact.”

And while Rab's suit and string vest would later be construed as the symbolic attire of the intelligent man whose prospects had been thrown in the grubber, Pattison's recollection is more prosaic: “As far as I can deduce, it was simply the last unused costume that day on the wardrobe bus.”

Nesbitt found a permanent home in Naked Video, and Pattison gave him a friend in Jamesie Cotter (Tony Roper.) Soon he had a wife, Mary doll (Elaine C Smith) and two sons and in 1988, Pattison’s sketch success was rewarded with his own sitcom, Rab C Nesbitt’s Seasonal Greet.

As the sitcom progressed, Pattison began to realise how Nesbitt’s DNA composition often closely matched that of Uncle Bernie. “Things seep into your head even when you don’t realise it,” he offers. “And this class DNA is shared these days by the likes of Limmy, the Still Game and Burnistoun boys, all of them brilliant and varied talents.”

Along the way, the sitcom had to endure criticism, of playing up to the Scots drunk stereotype. "The first series won the Royal Television Society award for best sitcom – that’s not bad for a stereotype. I would argue that the Nesbitts are like the Waltons compared to the reality that’s out there. Poverty is a character test people have to sit every day. It distorts and disfigures them. It brings a feeling of being second-class citizens even if they have first-class potential.”

There's bite in his voice when he adds: “And don’t forget we brought up millions of pounds from London to Scotland to pay for Scottish crews, actors and facilities.”

Rab worked because he was, in many ways, the ranting voice of insolence and reason. Thatcher’s Britain had to be shouted at, windows of opportunity needed to be broken. Rab broke them, and many TV taboos (managing to throw in plotlines as varied as cannibalism and bestiality, while hitting social nerves with groundbreaking stories of sexual harassment and transgender politics. Nesbitt was a clarion call for the Bernies out there, to let them flourish.

In short, Rab C Nesbitt was an icon, a voice that had to be heard. His show last screened in 2014. Will he ever come back in sitcom form? Or perhaps in a new TV programme? On a different station? "Who knows?" says Pattison. "I can’t say he’s dead. Let’s say he’s in a light coma, self-induced, unless circumstance wakes him up.”

• I Will Tell You This! My Life With Rab C Nesbitt is on BBC Radio Scotland on Christmas Day at 12.45pm