Most books are published for the entertainment of the middle class. There's nothing wrong with that, as they are the largest market. And at least in the United States, most people consider themselves middle class whether they are or not. But just because most readers and writers are middle class doesn't mean we don't get stories about the working class or those in poverty. We get a lot, good and bad. Much is "regional" as the city-centric would say, or rural noir, which can be great or it can wallow in squalor porn. No matter what the setting, all too often, the characters who aren't middle class are the villains, whether they be rich or poor.
Now, I like seeing a smug powerful fool get his or her comeuppance as much as the next reader, but this is a myopic view of the world. Not every trust fund baby is a psychopathic monster, and not every street kid wants to shoot you for your iPhone. The struggles of the middle class exist, but they are not universal. A car accident might ruin your day if you're financially stable, have good insurance, a job that understands when you're late, and so on. For people without those safety nets that many of us take for granted, a fender bender can make them jobless and homeless or put them in jail if they're on their way to see a probation officer. It can spiral their life out of control if they're driving thirty miles to the nearest methadone clinic, because we can't have pharmacies dispense the medication, which gets prescribed for non-addictive reasons from pharmacies all the time.
As Anatole France said, "In its majestic equality, the law forbids rich and poor alike to sleep under bridges, beg in the streets and steal loaves of bread." We think the playing field is level because we've always been on the pitcher's mound.
Why do I bring this up? I was reading The Jealous Kind, an excellent novel by one of my favorite authors, James Lee Burke. It has one misstep, when a somewhat sheltered teenager in the '50s not only knows all about illegal drugs but moralizes about it. If you've been around people who abuse opiates, or if you've taken them yourself, hopefully you don't buy the line that it's a moral failing. You don't take horse tranquilizers unless you are in some sort of pain, of the likes that I hope you will never experience. Now I don't condone Trainspotting as a lifestyle (choose life, yo) but neither will I sneer and tell them to 'just say no'. I find it a greater moral failing to assume you know how someone else got to where they are, than to ease your pain with a soporific substance. There are plenty of reasons not to use illegal drugs, I'm not here to argue it, but the no pun intended "high horse" attitude comes from a place of privilege, a place without misery. And if you need to feel better about yourself by denigrating those who succumbed to that misery when you didn't, you're hooked on another drug, sanctimony.
This can of course go the other way in crime fiction, when we care too much about "street cred." While I admire many writers who know crime first hand, writers deal in empathy, and while experience can help, it is not necessary. I don't look for blue collar backgrounds on jacket copy. Stewart O'Nan was an engineer, yet he writes some of the best stories about workers trying to get by, such as Last Night at the Lobster. I do look for characters who work for a living. One good example I read recently was Libby Cudmore's The Big Rewind, a hipster mixtape murder mystery set in Williamsburg; the main character is a temp who gets corralled into doing degrading odd jobs for her boss, which gave it the perfect verisimilitude to explain why she has time to sleuth around.
Another great recent use of class was in Megan Abbott's You Will Know Me, where the blue-collar parents of a gymnast prodigy struggle to give their daughter all the advantages that better-off parents can. They feel like frauds about to be exposed, and the tension is fierce and on point. Abbott grew up in the Detroit suburbs, but she knows noir--she has a PhD in it--and the class clash is often an integral part.
There's another book I won't name because I'm ruining the ending, where the sleuth slums with street kids and smokes pot laced with embalming fluid, but decides that the teenaged murderer of a pederast must serve his time rather than skip because... we demand justice for middle class victims, even if they molest teenagers. I threw the book at the wall, but I suppose that was honest to her character. She believed in the system, as a middle class kid; it had always served her well, why should that boy have something to fear from it?
What we do as writers is put ourselves in imaginary people's shoes; if they are always just like us, maybe we are squandering our ability. We should know our limitations and write what our heart tells us to write, but as the best crime fiction tells us, the heart may not always give the best advice. It might tell us to hate someone before we step into their shoes to see what stones we find.