When you scan a code, you get 10 points and once you reach 100 points, you can use the 'Island Scan' that will scan for a rare Pokémon not naively found in Alola and give you the opportunity to find and catch it. It allows you to scan QR codes and register Pokémon into your Pokédex with it.
The QR Scanner is a new feature that was added in Pokémon Sun and Moon.