Code Generator is part of an extra security feature called login approvals. If you turn on login approvals, you'll be asked for a special security code each time you try to log into your Facebook account from a new computer or mobile phone.
If you turn on the login approvals feature, you will be asked to enter a special security code or confirm your login each time you try to access your Facebook account from an unrecognized computer, mobile device or browser.
Facebook Login Alerts is a great feature that helps you improve the security of your account. Once you enable it, you will be notified when someone tries logging into your account from an unrecognized device or browser.