The ribbon is a ribbon, and ribbons do absolutely nothing.
However, the affection required to obtain the ribbon has a few other effects.
A Pokémon with high levels of affection will gain certain bonuses in battle and will interact with its Trainer in unique ways.
At affection level 2 and higher, a Pokémon will gain 1.2 times the normal experience from battles.
At affection level 3 and higher, a Pokémon may endure attacks that could otherwise make it faint and survive with 1 HP (including confusion damage). This can activate multiple times per turn.
At affection level 4 and higher, a Pokémon can sometimes:
Avoid attacks, even when they have 100% accuracy. This can activate multiple times per turn.
Shake off status conditions at the end of the turn.
At affection level 5 and higher, a Pokémon's chance of scoring a critical hit is doubled.
Pokémon with maximum affection may also receive the Best Friends Ribbon. In Pokémon Omega Ruby and Alpha Sapphire, a Pokémon with increased affection will need fewer Pokéblocks to max out its condition stats.
There are some cases where Pokémon do not get their affection bonuses, however (including the alternate quotes and other effects below). If a Pokémon Mega Evolves, it will not gain any affection benefits while it is in its Mega-Evolved state. More broadly, battles conducted over wireless or online play, or at the Battle Maison, Battle Institute, or Battle Tree, do not incorporate any affection benefits.