A few good con men . . .
The starship crew was stuck on a planet where the well-meaning schemes of ivory tower social engineers had created a nightmare of battling gangs. So they pretended to be the "Royal Legions" from a distant star kingdom in hot pursuit of an unspeakably evil and nearly all-powerful villain who was hiding somewhere on the planet.
Things went even better than they had hoped, and the planet was rapidly becoming civilized . . . and then the real Royal Flagship showed up. They thought they were doomed, but instead the new arrivals (who also weren't quite what they claimed to be) thought the crew had shown just the sort of initiative and ingenuity that the Interstellar Patrol was looking for. So they were inducted into the Patrol.
And that was just the beginning . . .