To put an Apple Magic Keyboard into pairing mode:
Connect it to your Mac with a Lightning to USB cable
Make sure the keyboard’s power switch is on
Select Bluetooth in System Preferences. Your keyboard will appear in there when it’s paired and ready