Ask a hundred people to identify the music that most offends them, and you'll get a hundred different answers. Some of us are offended by an artist's politics, some by their singing voices, some by their lifestyle or wardrobe. Offence can be caused by accident, when an artist misjudges a mood, or makes too sudden a change of creative direction. Even blandess can offend those who believe art's job is to provoke, cajole or inspire. But rock and pop have long embraced shock tactics and the deliberate deployment of offence, often used to underpin the sense of community that brings fans together – it's a tactic that stretches back to rock'n'roll's opening of the generation gap.

Usually it's what the music stands for that causes offence, in endless variations on that original exploitation of the generation gap. But what of an album that is in and of itself offensive? What would it sound like? What would it be for? Who would it offend, and how? And what would happen to the artist that made it? O'Shea Jackson, better known as Ice Cube, might know. During the late 80s and early 90s, he made a string of records that transcended the attention-grabbing offensiveness of even the group he had made his name as rapper and principal lyricist with NWA.

"With my records, nobody is safe – not even me," Ice Cube says. "Sooner or later, I'm gonna touch a subject that touches you. I don't think anybody's exempt – white, black, male, female, gay, straight; everybody kinda gets it. And I make it like that because I think everybody, in a way, deserves it."

His solo debut, AmeriKKKa's Most Wanted, delighted in its ability to needle listeners. Knowing that his likely supporters included middle-class liberals beginning to see rap as black America's most potent means of political protest, Cube threw in material calculated to push them away. By the time he released its follow-up, Death Certificate, in 1991, the then 22-year-old wasn't just lashing out at racist police and white liberals, he'd levelled his sniper scope on blacks, Asians and other rap stars. Rereleased earlier this year, it remains an album that sprays its venom in every direction at once: an equal-opportunities offender.

Throughout Death Certificate, Ice Cube is not merely outspoken, but outrageous, and is often the butt of his own deeply unsettling humour. The song Givin' Up the Nappy Dug Out is a series of sexually explicit lines about what an insolent Cube is going to do to a girl: but in the pre-song skit, it becomes clear the narrative takes place on her doorstep, after her dad has slammed the door in his face. What is, when stripped of context, indefensible misogynist garbage, becomes brutal, self-lacerating comedy – the impotent squealing of a brat who isn't getting his own way.

"My music is definitely an acquired taste," he says. "It's not there for everybody. I'm not doin' it to be ultra-outrageous so I can piss people off: that's not really the reason for it. It's just all about sayin' the shit I think needs to be said, and sayin' the shit I think is clever; sayin' what's funny, sayin' what's dope. And ironic: I wanna be ironic, too."

There are huge risks involved in making music that works in this kind of complicatedly provocative way, though: as Ice Cube discovered. The outrage that greeted Death Certificate on its release focused on two tracks: Black Korea, which addressed the relationship between Los Angeles' black and Korean communities in starkly confrontational terms, and No Vaseline, a scathing attack on NWA and their Jewish manager, Jerry Heller. Ice Cube was accused of racism and antisemitism; both tracks were removed from the UK version of the LP.

"I knew the record was politically lethal," he says today. "But I didn't think I was gonna get called antisemitic. That threw me off. I was like, 'They think I don't like a certain kind o' white people?' I got a problem with all the powers that be that got us in this fucked-up circumstance: I don't care whatever religion you are."

The key plank in the Ice Cube-as-antisemite argument are the lines in No Vaseline that refer to Heller's ethnicity. Ice Cube's defence – that he was simply stating the fact that Heller was Jewish, and using the word adjectivally – has an unlikely supporter: Heller himself.

"When he wrote Black Korea, I don't think that he's anti-Korean; when he wrote No Vaseline I don't think he's antisemitic," Heller told me in 2006. "I hate that song: it insulted me as a man, as a Jewish man, as an honest Jewish man. It insulted everything about me. But if I saw him on the street now, I wouldn't walk up to him and punch him, because I know he's not antisemitic. He's not anti-anything – he's pro-O'Shea Jackson."

More than a decade earlier, in a very different milieu, another musical iconoclast released a brace of albums that slip alongside Death Certificate into that very slim category of records that cause so much offence they put hard-won careers at risk. In 1978, David Allan Coe had apparently completed one of the most spectacular rags-to-riches journeys in music history: in and out of correctional facilities since his pre-teens, he lived in a customised hearse he parked outside the Ryman Auditorium in Nashville, becoming a fixture-cum-irritant in the city until the title track of his eighth album, Take This Job and Shove It, became a chart-topper for Johnny Paycheck.

Acclaim for Coe's songs – sometimes tender, invariably well-observed, often earthy but always funny with it – was running only a little ahead of praise for his versatile and emotive baritone. In the country and western industry, where forgetting to say grace can be enough to mark you down as a dangerous troublemaker, this outsider was on the verge of acceptance: a part of country's new and exciting "outlaw" scene alongside the likes of Waylon Jennings and Willie Nelson, with George Jones and Tammy Wynette among those recording his songs.

Coe's next move defied all logic. He independently released an album called Nothing Sacred: the songs were as crafted as anything on his major-label LPs, but the subject matter was of a decidedly different hue. Titles included Cum Stains on the Pillow, Masterbation Blues [sic] and F*ck Aneta Briant [sic], in which Coe managed to find a way of attacking the anti-gay campaigner that caused as much upset as she did.

Nothing Sacred wasn't the final nail Coe would attempt to hammer into the coffin he was busy fashioning around his own career. That came in 1982 with its follow-up, Underground Album. Among the X-rated material this time was something that pushed the outrage even further: a song in which Coe wrote from the point of view of a white man whose partner had left him and their kids for a black man. He called it Nigger Fucker.

"That's one of the reasons he's been banned for so long," says Hank Williams III, a latterday country music rebel who considers Coe a mentor. "He's looking at it from a non-racist, jail point of view: if you're in jail you're either with the blacks, the whites, the Latinos, or you're somebody's bitch. That's the mentality he was on."

Coe has consistently denied ever holding racist views – at the time of Underground Album's release, the drummer in his touring band was black – but too much of that self-flung mud stuck. By the time Napster was invented, Coe's name was being wrongly attached to MP3s of real race-hate country songs – the micro-genre he had set out to satirise. Shunned by the Nashville establishment that had been about to embrace him, his career went into steep decline. Bad business decisions and alimony to numerous ex-wives didn't help: for a time he was so hard up he briefly lived in a cave. Today, aged 71, the writer of a claimed 10,000 songs relies on gigs for his income – last weekend he played four two-hour sets at a biker festival in Florida. He declines interview requests because of poor hearing.

"He's living proof you can take it too far," says Williams. "He's just as good a writer as any of the old country legends were, but he burned as many bridges as you can, and that kinda catches up with you, I guess."

While Coe's career never recovered, Ice Cube's has followed a more surprising trajectory. The maker of what may well be the most offensive album of all time is nowadays often seen starring in and producing family-friendly Hollywood comedies. His music career may appear a sideline, but Cube's records seem to act as a safety valve. His ninth album, I Am the West, was released earlier this month, and contains flashes of the old bile. The song Hood Robbin' has Cube as a victim of foreclosure heading down to the local bank with a shotgun, meting out bloody vengeance on the architects of the credit crunch.

"Almost every rapper will admit that music has been the best therapy they've been able to ever have," Cube argues. "You're able to be heard, say your piece, talk shit no matter how aggressive it is, and get to release that out of yourself."

And if you upset everyone at some point along the way, it's a price you have to be ready to pay.

"The last thing you wanna do is be borin' an' predictable," he says. "I got records that I know are overboard" – he chuckles – "but pushin' those limits is what you do it for. These records, to me, were what hip-hop should be: it should be the good, the bad and the ugly, and everything in between, without apologising for the ugly. That's the essence. And that, to me, is truly art."

Are Ice Cube and David Allan Coe a bit too conciliatory for you? Let us know the albums you wouldn't play in front of the neighbours