You're the only person you can control
I'm not an oracle, and it's usually easier to solve other people's problems than my own… or at least seem to. Even still, when others ask me for advice, I try to help them consider what they can do to improve the situation. I take this approach even when the advisee is the recipient of someone else's bad behavior. If someone is being mistreated by their boss, for example, I might suggest that they quit, talk to HR, or ask for an internal transfer.
If the person seeking advice isn't feeling very receptive, the pushback might not take long. “They're the jerk. Why don't you tell them to be different!?”
If I can, of course, I will try to. At the same time, bad people—the truly awful, cruel, uncaring people of the world—they usually don't take advice. They don't care what I have to say. If they were so reasonable, they probably wouldn't be causing this problem in the first place.
To that point, I try to remind the listener, “you're the only person you can control.”
It's not fair, but remembering that may be the only strategy that has any chance of succeeding. Jerks are everywhere, and if your happiness depends on them being better, you're probably not going to be very happy.
None of this is to excuse the importance of listening to others and trying to understand their pain without trying to fix anything. I could always do a better job of that.
If you do want something to change, focus on what you can do differently. It may be the only viable solution, because you're the only person you can control.