... Except of course it doesn't.
Criminals are cool. It might be a terrible thing to say, but it's true. One of the most enduring images in modern fiction is that of the glamorous gangster - a streetwise, self-made man who's rich, powerful, badass, irresistible to women, fashionable, and unfettered by conventional morality. In short, a perfect Escapist Character for times when being a good guy is just too dull.
On the flip side being in organised crime is scary, paranoia-inducing and the story probably won't have a happy ending.
Violence might be abhorrent in Real Life, but on the big screen it can be just another way to get the audience's adrenaline flowing, and there's nothing wrong with that. Besides, in fiction, it doesn't matter how many dogs you kick as long as you look really cool when you do it.
This trope was widely popularized in the US during The Roaring Twenties, when Prohibition made organized crime big business and the gangster became one of the iconic figures of the era; and The Great Depression, where bank robbers were seen as striking at the greedy and foolish banks that got the country into this mess. Of course, it has roots much further back in history - the popularity of outlaws like Jesse James and Billy the Kid in the American frontier era certainly counts, and even as far back as Robin Hood it was cool to steal. However, modern works are more likely to subvert or deconstruct this trope as play it straight. Indeed, the so-called "rise and fall" narrative is such an integral part of the gangster genre that it now makes straight examples of this trope nigh impossible.
Sub Trope of Evil is Cool and closely related to Do Not Do This Cool Thing. See also Neighborhood Friendly Gangsters.
Baccano — Even the most innocent and endearing characters in the series have connections to either the Mafia or Camorra.
Firo actually invokes this in the Light Novels, citing one of the reasons for joining the Camorra was "to be like the Italians who appeared in those movies and stories."
Mostly avoided in Gun Grave anime: while Big Daddy's mafia is quite stylish and honorable, and there are some scenes with cool cars and houses it is never a major point of the series.
The Godfather and its sequels apply the trope to some, but not all, of the characters. Most of the lives of the gangsters are glamorous, with Vito's reign in particular being idyllic. However, the hardships end up destroying the happiness of Michael's family and lead to the violent murders of Sunny and Fredo.
Arthur Penn's heavily fictionalized portrayal of the title bank robbers in Bonnie & Clyde, one of the original "New Hollywood" films, is a very influential example.
Goodfellas, despite being famous for its more "gritty" take on The Mafia. Since it's based on a true story, it's largely a straight example for the first two hours (with a few scenes showing the dark side, like being arrested- but even then it's an idyllic stay in jail), and then a ruthless, horrific subversion for the last hour....But the main character, in-universe and in Real Life, still wanted to be a gangster even after all that.
Public Enemies — Dillinger and his squad are filthy rich, helps out the common man caught in a financial bind, can woo and bed a different woman every night if they wish, and are generally seen having the times of their lives when they're not being mowed down by the feds. Melvin Purvis, his team, and J. Edgar Hoover are depicted as asexual, aloof, and mechanically devoted to the task of catching crooks, often times descending into wanton destruction of civilian property and citizens.
There's a bit of a cottage industry in averting this trope for more serious works.
American Gangster subverts this with Frank Lucas being a believer in dressing conservatively both as a way to avoid the attention of the law and as a sign of strength. In fact, the only time he disregards this personal standard with a flashy fur coat and hat for a night out turns out to be the biggest mistake of his life as the cops notice this fancy dressed newcomer in the New York crime circles and they investigate him.
The film version of Layer Cake subverted this trope while deconstructing it. At first the protagonist makes dealing in cocaine look like easy, stylish money with and excellent pension plan. By the end, he's been through hell and back just trying to retire into obscurity, and the audience is shown via the medium of Black Comedy just how lame the criminal underworld can be.
In Bugsy Malone the song "Bad Guys" is sung by most of Fat Sam's gang - all about how brilliant it is to be gangsters. Dandy Dan's gang don't have a song, but they all probably apply as well.
Sin City plays with this. The mafia is seen as living a rich and powerful lifestyle but many of them get killed off en masse by the heroes. Then again, they remain in power despite the heroes' efforts, usually. And in some cases, they outlive the heroes but usually at great cost.
Averted in Alpha Dog. Right from the start it's clear that these are a bunch of loser assholes that only an idiot would want to emulate.
Averted in King Of New York. Jimmy relishes the gangster lifestyle and its perks but is completely unprepared for the harsh side of it. Frank clearly derives no pleasure from it, detests many of the men in the trade and suffers from deep self-loathing over the things he's done to gain power.
At the end of Johnny Dangerously, Johnny admonishes the audience that "Crime doesn't pay" — and then when his limo pulls up and two dames drape themselves over his arms, he admits, "Well, it pays a little."
Vlad Taltos. Bit of a deconstruction in the later books of the time line, but Taltos in particular is made of this.
Live-Action TV
Weirdly seems to be the MO of the last decade of General Hospital.
The Sopranos can make gangsters look so cool at some times and so pathetically uncool at others. It's really a Deconstruction of this trope more than anything else. The consequences of living the life of a complete sociopath are thoroughly examined, and it's not glamorous. The people who complain that The Sopranos somehow glorifies the Mafia have clearly not seen very much of it, or are basing their opinions on promos. The show makes working in the Mafia look alternately paranoia-inducingly scary and mind-numbingly dull. Sure, Tony has a nice house and makes a lot of money, but he has to face his boorish family all the time (and vice versa), and he always has to worry about his "friends" turning on him, maybe leading to his arrest or assassination. When Christopher gets made, the promotion means that he's under even more pressure to earn.
Sam Adama from Caprica, enforcer and hit man for the Tauron mob, caring uncle to William Adama, and, well, possibly the coolest character in the show.
As far back as Abed from Community can remember, he always wanted to be in a Mafia movie.
Inverted in the 1990s version of The Untouchables, a boy gets some odd jobs from Al Capone's gang and finds he likes the bling involved. When Eliot Ness finds out, he drags the boy to a morgue to show what will likely happen to him if he wants to be a gangster. When the kid retches at the site of a dead gangster with his throat bloodily slashed, he gets the point.
Being set during Prohibition and The Roaring Twenties, Boardwalk Empire is full of this one. Half of the main cast are either really well-known gangsters (Arnold Rothstein, Johnny Torrio, Nucky Thompson, Jim Colosimo) or young gangsters just starting to make a name for themselves (the fictional Jimmy Darmody, and the very real Meyer Lansky, Charlie "Lucky" Luciano, and Al Capone).
Music
A huge part of Hip-Hop and Gangsta Rap culture.
Notably, in Jay-Z's American Gangster, (inspired by the Russell Crowe/Denzel Washington movie of the same name) the intro contains a line which is this trope, word for word.
Rap music is just as likely to deconstruct this trope as well, showing the downsides of being Gangsta: Sure you're badass, if you don't mind dealing with prison, drug addiction, friends dying young, your own life being in jeopardy, siring children out of wedlock, etc.
A genre that glorifies and glamorizes drug trafficking culture.
in Mexico.
Tabletop Games
In Shadowrun, the player characters are specialized criminals for hire, living double lives on the wrong side of the law. The mega-corporations often use them as deniable/disposable assets for espionage and sabotage against each other, as well as "extraction" (kidnapping) and "wetwork" (assassination).
However, many professional Shadowrunners looks down on any Runner who tries to make an entertainment career out of it.
Theatre
In Anything Goes, the Rev. Dr. Moon is Public Enemy No. 13 and wants to be higher on the list. The greatest disappointment of his career is finding out that he's no longer a wanted man.
Actually, his name is Moonface Martin, and he's just posing as a minister. He helps a stowaway, Billy Crocker, pose as Public Enemy No. 1. At first the two of them are treated as celebrities, but when Billy's true identity is learned, they're both thrown into the brig.
Deconstructed in GTA IV, the main character, Nico, comes to America so that things can be different, after his life as a soldier, sailor and people-smuggler. His cousin's debts, bad blood with the Russian Mob, and his illegal immigrant status pulls him back to doing crime for money, but he in no way feels good about it. And depending on the players actions, it ends up costing the life of his girlfriend or his cousin. The player still might enjoy it though...
Ditto in The Ballad of Gay Tony, since your main reason for breaking the law is to pay back debts to various criminals.
Super-duper subverted in Vice City Stories, where the main character isn't even a criminal (and is probably the closest thing the game has to a good character) and is forced to engage in deviant acts by his drug-running commanding officer in the Army.
This sentiment is commonplace in Mafia. While discussing the upcoming sequel, one of the developers called the game "a tribute to gangster movies" and claims this aspect will be toned down in said sequel.
Although Mafia II just simply went down the route of having two-thirds of the game glamorize being a gangster before having everything fall apart for the protagonist in the last act.
Also subverted in Saints Row 2. The missions against the Brotherhood quickly become mean-spirited enough to make some players uncomfortable.
Not just the Brotherhood. What Gat and the Boss do to Shogo Akuji—i.e. bury him alive while he begs, screaming, for a Mercy Kill instead— also hit some players pretty hard. When it's not being balls out cool or fun, Saints Row 2 delves into some truly horrifying areas.
Played straight in the rest of the game. Pimping out your hideouts, customizing your rides, building your gang, it's all really cool.
While the game certainly glamorizes the life of a modern gangster - and the characters themselves definitely enjoy this lifestyle - it does have one notable subversion: as cool as the protagonists are, it still isn't enough to make up for the horrific acts they commit and their general sociopathy. Moreover, although this is subject to interpretation, it can be seen that this is supposed to be how the audience reacts.
And in the third game the Saints have become a successful brand name. Crime is now so cool there is an energy drink named after your gang among other things, while you are still going on murderous rampages. Not only that, but there seems to be one "Professor Genki" in a nyancat suit driving a clown car with a cannon that ejects pedestrians. In short, gansta cool seems to have left the building in favour of Death Race 2000 or Twisted Metal style mass psychosis.
In Pokémon, you do not ignore Honchkrow, Krookodile, or Scrafty. Unless you want to get sicced by one of their followers. Or they could attack you personally, which is even worse. Or they could all gang up on you and kill you plum dead (Scrafty is especially notable for this). Even their physical appearance screams gang member (boss in Honchkrow's case); Honchkrow has the Al Capone black fedora hat (and its Platinum sprite appears to be giving orders), Krookodile has a bandit's mask and striped burglar outfit (plus those big bad jaws that crunch automobiles), and Scrafty... well, go to Bulbapedia and look for yourself. Does it surprise you that they have fantastic battle capabilities and are all part Dark-type?
Krookodile's and Scrafty's evolutionary lines are also used by the gangsters on Route 9. Some of them have a picture of Krookodile's head◊ on their jacket!
Even if they're not specifically gangsters, many of them are either employees or patrons of the title speakeasy, and it takes place during the Prohibition. In other words: still criminals. The author even jokingly suggests that the little old lady who innocently tried to dispose of some bad sardines down her sink drain is a criminal based on sanitary disposal laws at the time.
Trap Jesus: You think when I was nine, I wanted to trap? Sweet Tea Mob: Uh, nope, no... Trap Jesus:Hell yeah I did! I look around this city, see nothing but a gang of fiends on every corner of every block, and all I could think is, what a lucrative business opportunity. And now look at my swag. I'm the most biggest, notorious, dope man in the South. I'm a BOSS.