FarmVille was designed from the ground up around Facebook's social graph, and neighbors were central to that design.
Visiting a neighbor's farm let a player help out in small ways — fertilizing crops, pulling weeds, raking leaves, or chasing away pests — each of which earned a small amount of XP (fertilizing, for example, was worth 5 XP). New players were further rewarded for their first 20 neighbor visits, earning 5 XP and 20 coins per visit during that window.
More neighbors meant more gifts: players could send and receive gift items to use on their own farms, and having a larger neighbor list meant more potential gifts flowing in.
This social design doubled as FarmVille's growth engine. The game posted directly to a player's Facebook News Feed for major actions, which acted as free, organic advertising to that player's entire friend list — a big part of how the game grew to tens of millions of users so quickly.
That same mechanic eventually drew a lot of criticism: as FarmVille (and similar games) flooded News Feeds with gameplay updates, "how do I stop FarmVille notifications" became one of the most common tech-support searches of 2010. Facebook eventually restricted how much games could post to feeds and send as notifications, which sharply slowed FarmVille's viral growth afterward.