The setting at the time was an important factor for the type of people that the story was about; change the type of people, and you change the entire meaning and possibly plot of the story itself. O. Henry sets the story in "Greenwich Village" which he satirically describes as a place that
"the art people soon came prowling, hunting for north windows and eighteenth-century gables and Dutch attics and low rents. Then they imported some pewter mugs and a chafing dish or two from Sixth avenue, and became a 'colony.'"
His tone rather makes fun of these artists that come seeking low rent and a place to paint. It is a community of struggling artists that band together under their struggle to make it big or known in their artistry. Because of this, Sue and Johnsy are roommates. They are both struggling artists. In the time frame that O. Henry wrote, two women roommates weren't very common, but probably possible more in Greenwich Village than in other places. If it were set elsewhere, the liklihood of Sue and Johnsy being together as roommates would have been rarer. Then, to have an old bachelor man living right below them was also unusual; Behrman was another struggling artists. The nature of the setting provided a wonderful place for a bunch of rather random types of characters to be realistically thrown together.
If it had been set elswhere, the probability of these three main characters living so close together would have been unlikely. O. Henry needed a place for them to be, and for them to be artists, for the ending of Behrman painting the leaves right outside the window to become a reality. If it had been a house in the country, all spread out with no neighbors, it would have been unlikely that Behrman would have been in their house, and that he would have painted a leaf. The setting is crucial in throwing these characters together in a unique artistic friendship, and providing a close proximity for the leaf to have been painted. Take that away, and the entire story would have changed; it would have had to have been much longer, with more creative reasons for these characters to have known each other, and included a lot more stretches of believability.
I hope that those thoughts helped; good luck!