Question: Assume this city is relatively large by late medieval standards, around 200,000 people. The city is mainly a site for trade due to its geographically central position and being on a river. Also, because it is geographically central, it also means the city is important for the government to project power.

**What might be the benefits for this same government to sanction certain crime within this important trade city?**

Crime that would be considered legal within city limits ranges from murder, burglary, trade of illicit substances, and racketeering. This is all under the condition that the crime does not directly affect the government's activities.

Answer: 
I wonder if you have a too modern view of the state -- by the people, for the people. Over much of history it was by *some* people, for *some* people.

* **Illicit substances**  

Very much in the eye of the beholder. In much of the West, alcohol is legal (and taxed) and cannabis is not. Say you have strong merchant guilds interested in the trade in those substances, and they might have gained permission to do so. Also consider the [Opium Wars](https://en.wikipedia.org/wiki/Opium_Wars).
* **Racketeering**  

Just who is exploited, and how? Look at the rise of firefighters in [ancient Rome](https://en.wikipedia.org/wiki/Marcus_Licinius_Crassus#Rise_to_power_and_wealth). Early on they were for-profit companies who charged whatever the market would bear when a house was on fire. Or take a medieval craft guild, regulating prices, quality and competition and making sure that guild masters had a decent living.
* Special case: **Tax farming**  

The government sold the right to [collect taxes](https://en.wikipedia.org/wiki/Farm_(revenue_leasing)). The interests who paid a hefty sum now try to squeeze money out of the city to cover their costs and make a profit on top. Not everybody is allowed to racketeer, but from the perspective of the victims some rackets are legal.
* **Burglary**  

This one is difficult. When it is made legal, powerful factions like the merchants and guilds mentioned above must guard their properties without the help of a city watch. But do you know the proverb *only the rich can afford a weak government?* Say burglary is not legal, the rules against it are simply not enforced by the government. That is left to merchants and shop-keepers, who form associations (see *racketeering*) to employ guards and [thief-takers](https://en.wikipedia.org/wiki/Thief-taker).
* **Murder**  

As above, making it a kind of *civil* offense requiring [weregild](https://en.wikipedia.org/wiki/Weregild) if the relatives of the victim are strong enough to insist.
Instead of government-sanctioned crime, what about a small area with a different government or no government? It could be an independent city where three or more large countries meet, and none of the countries can take it over because the others wouldn't let them. This also gives a good explanation for why there would be lots of devious machinations going on by various government agents in the city, and it would be a prosperous trade hub if it is the best route between those nations.