Holmes loves the city: after all, it's "a hobby of [his] to have an exact knowledge of London" (League.148). The countryside? Not so much. In the scattered households of the countryside, Holmes sees a lot of vulnerability to cruelty with no helpful neighbors on hand to stop it. Consider the events of "The Speckled Band," "The Engineer's Thumb," and "The Copper Beeches." All of these involve long-term abuses that go pretty much unnoticed because they occur in isolated country houses.
At the same time, the city puts lots of different kinds of people side by side, which is like an invitation to quite unexpected trouble. He takes advantage of this fact in "A Scandal in Bohemia," when he stages a riot outside of Irene Adler's house. Other examples of volatile, dangerous city life include poor Henry Baker's assault by some toughs in "The Blue Carbuncle" as well as the opium dens of "The Man With the Twisted Lip."
In Holmes's adventures, the crimes that take place in London occur as a result of the city's growing diversity and its economic wealth, while the crimes that take place in the countryside are often conspiracies that depend on the isolation of the victim.
By setting the Holmes stories in London, Conan Doyle takes advantage of the city's importance as the center of the British Empire to represent multiple races and classes living side-by-side.