Even if the QR data is nothing to do with Pokemon Ultra Sun & Moon the game will crunch some numbers and give you something in exchange for scanning it. The truth is, you can scan just about any QR code and the game will read it and do some math in order to figure out what Pokemon to attach to that QR code.
The QR Scanner allows you to use the Nintendo 3DS cameras to scan QR codes out in the real world. Once you're a little way into the game you'll unlock this feature - it'll pop up as a new icon in your Pokedex. That feature makes a return in Pokemon Ultra Sun and Pokemon Ultra Moon, though as in the original game you'll have to unlock the QR code scanning functionality first. One major new feature of Pokemon Sun & Moon that proved extremely popular was the ability to scan QR codes and have that pop out little rewards in the world, or have it fill in your Pokedex.