Go to Settings -> Passwords -> Password Options and turn On AutoFill Passwords and Passkeys. Now, when you receive a one-time verification code, your iPhone automatically detects it from the Message app and places it above your keyboard. You just need to tap the code to use it.