Since whatsapp users do not register using something like username / password the authentication is handled by the app using the sim card and ability to recieve an sms on a given number.
When Whatsapp started whatsapp web, a web client for PC / Mac users, they needed a way to authenticate the users there. This is where the QR code is used. Once the user scans it using the app he authorizes the computer and some tokens are stored in the browsers localStorage.