Friendship ... is a measurement of how much a Pokémon is attached to its Trainer and enjoys being in their care.
It affects the evolution of certain Pokémon, the power of Return and Frustration, and the availability of a few in-game items and Ribbons. Certain events increase a Pokémon's friendship (gaining a level, walking a certain amount of steps) or decrease it (fainting, using herbal medicine).
In all games, friendship is a value that ranges from 0 to 255 (stored as a single byte). Certain NPCs in the games will evaluate the friendship of a Pokémon in the player's party.
A Pokémon's friendship is generally set when the player first obtains it. When a Pokémon is first caught from the wild, its friendship starts at its base friendship value. Trading a Pokémon also resets its friendship to its base value. A Pokémon caught in a Friend Ball starts with 200 friendship instead of its base friendship, while a Pokémon hatched from an Egg starts with 120 friendship.
Friendship is generally increased by taking good care of a Pokémon. Keeping a Pokémon in the player's party, raising it, using items on it, and getting it groomed will all increase a Pokémon's friendship. Letting it faint and using bitter herbal medicines on it will decrease a Pokémon's friendship.
From Generation III onward, if a Pokémon was caught in a Luxury Ball, any increase to its friendship is boosted by 1. In Generation III (except Pokémon XD) and from Generation V onward, if a Pokémon is currently at the same location where it was caught (its met location), any increase to its friendship is boosted by 1. If a Pokémon is holding a Soothe Bell, increases to its friendship are boosted by 50% of the change—in Generation III, the increase is applied to the original change in friendship; in subsequent generations, it applies to the friendship change after including Luxury Ball and met location bonuses.
In Generation V, the Befriending Power Pass Power boosts any increase to friendship by one to three points depending on the strength of the power used.
None of these effects change the amount of friendship lost for negative changes or for changes of 0 (such as using an X Attack on a Pokémon with high friendship).
There are Pokémon that evolve by friendship, which can only evolve if they have 220 friendship or more. Additionally, the moves Return and Frustration vary in power depending on how high or low the user's friendship is.
From Generation IV onward, there is a Ribbon for Pokémon with maximum friendship, the Footprint Ribbon.
Some NPCs also only give gifts or teach moves when the player's Pokémon has a certain amount of friendship. Specifically, a Pokémon must have maximized friendship to learn Draco Meteor, Frenzy Plant, Blast Burn, Hydro Cannon, Grass Pledge, Fire Pledge, or Water Pledge in any generation.
This is the basic information for all forms of friendship in the Pokemon games that also correlate with Gen 5 according to Bulbapedia. Here are specific features for Gen 5.
Generation V introduced Befriending Power as a Pass Power to boost friendship gains.
Friendship boosts do not apply to the massage in Castelia City.
In the Generation V games, an NPC who will evaluate the friendship of the Pokémon in the player's party can be found in Icirrus City, with a second NPC only found in Nacrene City during Pokémon Black and White who checks the player's first Pokémon. In Pokémon Black 2 and White 2, the player may also contact Bianca on the Xtransceiver to have their Pokémon's friendship rated.
Beauty Salon: getting a Royal Cut W2 +50
Beauty Salon: getting a Beauty CutB2 +40
Beauty Salon: getting a Smile CutB2W2 +30
Massage (Castelia StreetBW/Medal OfficeB2W2)
"The massage has made your Pokémon [...] friendly to you!" "much more" (6%) +30
"more" (20%) +10
"a little bit more" (74%) +5
Beauty Salon: getting a ShampooB2W2 +20
Café: getting a Friendly ComboB2W2 +20
Beauty Salon: getting a BrushingB2W2 +10
Café: getting a Friendly LunchB2W2 +10
Using friendship-raising Berries +10 (if friendship is between 0-99) +5 (between 100-199) +2 (between 200-255)
Café: getting a Friendly DrinkB2W2 +5
Level up in battle +5 (between 0-99) +4 (between 100-199) +3 (between 200-255)
Battling against a Gym Leader, Elite Four member, or the Champion (whole party)
+5 (between 0-99) +4 (between 100-199) +3 (between 200-255)
Using a vitamin +5 (between 0-99) +3 (between 100-199) +2 (between 200-255)
Using a wing +3 (between 0-99) +2 (between 100-199) +1 (between 200-255)
Walking 255 steps (50% chance, whole party) +2 (between 0-199) +1 (between 200-255)
Learn a TM or HM +1 (between 0-199)
Using an X item +1 (between 0-199)
Fainting: If opponent is less than 30 levels higher -1
If opponent is at least 30 levels higher -5 (between 0-199) -10 (between 200-255)
Using EnergyPowder or Heal Powder -5 (between 0-199) -10 (between 200-255)
Using Energy Root -10 (between 0-199) -15 (between 200-255)
Using Revival Herb -15 (between 0-199) -20 (between 200-255)
This looks like a mess on mobile