why is unregister_setting() undefined?

That function is only available from the wp-admin section of the site. The file that contains it is only loaded as part of the wp-admin. You need to wrap it in a hook function:

function unregister_users_can_register_setting() {
    unregister_setting('general', 'users_can_register');
}
add_action('init', 'unregister_users_can_register_setting');