In an unlikely turn of events, President Trump, in alliance with the ACLU, has thrown his weight behind a criminal justice reform bill that's wending its way through the Senate.

The bipartisan First Step Act would focus on rehabilitating prisoners, and reduce mandatory minimum sentences for drug-related crimes. Trump's motives for supporting the bill aren't entirely clear, but there's no denying that prison reform in America is long overdue. And while there have been many cases of conservatives selling out their principles to remain in good graces with Trump — often to the detriment fo the country as a whole — this is a learning moment for both conservatives and libertarians. It demonstrates why it can sometimes be useful to try to gain favor with such a malleable president.

Trump's most stalwart backers are going all-in on this bill, and labeling anyone who isn't as an obstructionist foe of the president. When Sen. Tom Cotton (R-Ark.) penned a National Review op-ed this week opposing the legislation, Candace Owens, a pro-Trump conservative provocateur who is big on the MAGA circuit, quickly pounced, tweeting that Cotton was "second guessing Trump, & denying millions of blacks the opportunities presented via the First Step Act."

This reaction, and Trump's support for the bill, is somewhat puzzling. While some Tea Party senators, including Mike Lee (R-Utah) and Rand Paul (R-Ky.), have been supporters of criminal justice reform, the trend among conservative Republicans has, in many ways, reverted back to a more law-and-order stance under Trump. Case in point: Ted Cruz (R-Texas) has turned against First Step. And don't forget: Jeff Sessions may be out as attorney general, but during his tenure, he was skeptical of sentencing reform.

So why is Trump on board? There are a lot of potential motivations. The first, of course, is his own approval. In June, Kim Kardashian persuaded Trump to grant clemency to Alice Johnson, an African-American woman who had received a life sentence for a nonviolent drug offense. The president received overwhelmingly positive feedback for this move, and has grown more interested in providing relief from harsh sentences ever since.

Perhaps staring down the barrel at Special Counsel Robert Mueller's Russia investigation has also made Trump more sensitive to the plight of people who find themselves in the crosshairs of overzealous prosecutors. His former campaign chairman, Paul Manafort, is already in solitary confinement, and there have been persistent rumors about the probe ensnaring longtime political adviser Roger Stone and even members of the Trump family.

First Step also affords Trump another chance to strike a blow against the Clintons. After all, former President Clinton signed a crime bill into law in 1994 — with Hillary's intermittent support — that contributed to the problem of mass incarceration. Trump could reverse some of its ill effects, and then loudly take the credit.

This is also an opening for Trump to push back against charges of racism, as these reforms would disproportionately benefit people of color, who are vastly more likely to be incarcerated for minor drug-related offenses in America than white people. This comes in handy amid images of tear gas at the U.S.-Mexican border and after a midterm election in which minority voters helped hand the House of Representatives to the Democrats for the first time in nearly a decade.

Finally, Trump is no proponent of legalizing drugs, but he is softer on the federal war on drugs — especially concerning marijuana — than Sessions and some of his other allies. The drug war has played a substantial role in filling our prisons with nonviolent offenders, and Trump has signaled that he may support a bill changing America's drug laws.

Whatever the motives of Trump and some of his more prominent supporters, here is a rare, even counterintuitive, example of fealty to Trump potentially leading to a good civil libertarian outcome.