When using AirPlay to connect with an AppleTV box or other SmartTV that supports AirPlay, you may need to enter a Passcode. Whether or not this is a one-time requirement - or the Passcode is required each time you connect - will be determined by the individual settings of the AppleTV/SmartTV.
Consider that AirPlay is a broadcast technology that permits connection to any device within range. The Passcode ensures that you are in the same room as the target device - as only if you can see the screen of the target device will you be able to see the screen upon which the Passcode is displayed. As such, if the target is in an adjacent room (such as a neighbouring hotel room), you won't be able to connect and display content that may be unwanted or inappropriate.