SPOCK: Doctor Sevrin, I'm in a position to help you and your group. I can use the resources of the Enterprise to determine whether or not Eden actually exists and to plot its exact location. I can present a case to Federation to allow you and your group to colonise that planet. Neither you nor your people are at present charged with a crime. However, incitement to disaffection is criminal. The Federation will never allow the colonisation of a planet by criminals.
—"The Way to Eden"
Is the Federation a republic? Unifying so many planets and cultures requires tolerance for diversity. The "space hippies" in "The Way to Eden" broke laws—stealing a spaceship, attempting to violate treaty territory. Still, the vastness of space and abundance of "Class M" planets (or so it would seem in TOS) is the ideal solution for frictional differences.
Meanwhile, there are many cases where the Prime Directive has been violated—by Kirk—along with the prohibition against colonization by criminals:
KIRK: Mister Spock, our heading takes us near the Ceti Alpha star system.
SPOCK: Quite correct, Captain. Planet number five there is habitable, although a bit savage, somewhat inhospitable.
KIRK: But no more than Australia's Botany Bay colony was at the beginning. Those men went on to tame a continent, Mister Khan. Can you tame a world?
—"Space Seed"
Considering Khan's war crimes, Kirk's solution is incredibly generous. It violates Federation law, as described by Spock in "The Way to Eden." Yet Khan's "crimes" were committed on Earth before warp drive and first contact, thus making it an Earth concern. (Except for that little misunderstanding about Khan trying to seize a Federation starship.)
The contrast between these two episodes probably does not have an "in-universe" explanation, but it does question how much law is "just enough" to protect people while permitting the maximum freedom and diversity.