How did the man with leprosy come into the city? Anyone with leprosy should stay outside the city until he is clean.


  Leviticus 13:46  He is to live by himself in a home outside the encampment.


With reference with below verses, we see Jesus travelling through Galilee preaching and driving out demons.


  Mark 1:38-39  Jesus replied, “Let us go somewhere else—to the nearby villages—so I can preach there also. That is why I have come.”
  So he traveled throughout Galilee, preaching in their synagogues and
  driving out demons.


Suddenly, man with leprosy came to Jesus for healing.  


  Mark 1:40  A man with leprosy came to him and begged him on his knees, “If you are willing, you can make me clean.”


How did the man with leprosy get into city? He was not supposed to come into the city, right? 

I assume many people was following Jesus to see his miracles but if so how did his person with leprosy come to Jesus through all these people? Or Jesus outside the city?
The biggest clue here is in the very last words of the verse "outside the encampment". Just with a superficial reading you can see that the cultural context between the command being given, and the point in time which the gospel refers to, are completely different.

This in itself isn't enough to answer the question though because you could argue that the city is effectively the new "encampment" and the verse might still apply despite the change in context.

To answer this it's important to understand more of the differences in context, and what exactly the Leviticus verse was originally addressing. When the command was given, the Israelites effectively lived "in the presence of God" (signified by the pillar of fire/smoke). It was a theocracy, with God giving commands to Moses directly. Because of such close communion with God, there was a degree of ceremonial purity that was necessary even to reside in the camp- the idea is that ceremonial impurity can not exist in the presence of God.

After the time in the Wilderness, Israel became a nation, and progressively became more like the other nations around it. The King ruled, and the King didn't necessarily submit to God. There is no one City that can really be described in such a way that would be equivalent to "the encampment" - rather the people are scattered across several settlements and cities, in much the same way as any other nation would be. Instead, most of the ceremonial purity laws now apply more directly to the Temple, as this is now the place that is considered to be where God's presence rests.

By the time we get to the Gospels, the Temple has been destroyed, but also rebuilt, and the nation of Israel doesn't even rule itself (politically), but is under the rule of the Romans. So really, the man with leprosy was in the city because he had every right to be in the city. It might be more of an issue if he was wandering around the Temple.