Pairing an Apple Magic keyboard with Window 11 and 10 is pretty easy, but not documented by Apple for obvious reasons.
1. First off, let’s turn on the Magic Keyboard
2. Then in Windows load up Bluetooth system settings by pressing Windows logo on your existing keyboard and type “Bluetooth and other devices settings”. (If you haven’t an existing keyboard connected at all you will need to use the mouse to navigate to the same area in System settings.)
3. Click on Add Device
4. At the "Add a Device" click on Bluetooth
5. The Magic Keyboard will be listed, select it from the list.
6. The Windows 11 Bluetooth will give a random number on the screen that needs to be entered on the magic keyboard then press the Return (or Enter key).
7. If everything has work correctly the magic keyboard will be paired.