In general, when you say this phrase, you mean establishing boundaries between you and your neighbor helps you both know how to act and respect each other's space and privacy. For example, if you and your next door neighbor know for certain where your yard ends and his begins, then there won't be any disagreement about which of you is supposed to mow that bit in the middle. More generally, if you've established that it's not okay for your neighbor's kids to come play on your trampoline and make lots of noise any time they want, then you both experience more peace and less conflict. Boundaries can make for a better relationship between neighbors. For a more detailed (and scholarly) exploration of this proverb, please click here.
In Robert Frost's poem "Mending Wall," the speaker considers this phrase as he and his neighbor work on rebuilding the damaged wall that marks the boundary between their fields. The speaker wonders why they even need the wall, since it's easy to tell where one neighbor's field ends and the other's begins, but the neighbor keeps thoughtlessly saying the phrase ("Good fences make good neighbors") without explaining it, as if it's self-explanatory, or as if the neighbor perhaps doesn't know what it means.
The funny thing you might consider here, in the poem, is that the very action of rebuilding the fence together every year is what brings these neighbors together. It's why they're spending time together; it's why they're talking. By making the fence "good" again, by fixing the gaps and the places where it's crumbling away, these two men are actually being better neighbors. That is, they're spending time together doing something productive, not just ignoring each other.