A Friend Code is a 12-digit number unique to your 3DS or 2DS system. You can register other people’s Friend Codes and add them to your friend list. Whenever someone on your friend list goes online, the system will let you know by blinking the light on the right side of the hinge (for the 3DS; I’m not sure how it works for the 2DS) Most 3/2DS games with online connectivity will also highlight friends when looking through a list of online users.
The Friend Safari is a location in X/Y that is populated by Pokémon according to how many friends you have registered. It starts out with no Pokémon, but for each registered friend, 3 Pokémon species will become available. The species are determined by the friend’s code, soif two people befriend the same person, they will get the same Pokémon, although you cannot access Pokémon from your own Friend Code. Pokémon in the Friend Safari are not available elsewhere in X/Y, have at least 2 perfect IVs, are more likely to be shiny, and have a chance of having their Hidden Ability.
More information about Friend Codes can be found here, and information about the Friend Safari can be found here.