First you have to get a lot of money. Once that is achieved, then the process becomes fairly straightforward, as this BuzzFeed News clip explains (via Mark Frauenfelder).
If you have the money to hire a powerful, well-connected attorney, that person can meet with the top people in the district attorney’s office and negotiate favorable plea deals that avoid trials and jail time even if the career prosecutors who are actually handling the case want to take a person to trial.
The only plea deals that poor and otherwise powerless defendants (who often have the services of overworked and underpaid public defenders) get are coercive ones, when they are threatened with a laundry list of serious charges that can put them in prison for a long time and then told that if they plead guilty to a few, then they will get reduced sentences. Some defendants agree to this deal even if they have not committed any crime, out of fear that they will spend a long time in prison. But even a relatively short stint in prison (sometimes just because they cannot afford bail like rich people can) can destroy people’s lives by disrupting their families, causing them to lose their jobs, and making future employment difficult.
It also helps rich people if the District Attorney is (as discussed in the case shown in the above clip) Cyrus Vance, Jr., a notorious friend of the wealthy and powerful and of people who donate to his election campaigns. We already encountered him in the context of the vigorous prosecution he launched against a small Chinese-American bank named Abacus that was trying to do the right thing while ignoring the massive abuses of the big banks. Vance also dragged his feet over charging Harvey Weinstein who was a a major campaign contributor.