Try the following that worked to connect an old A1016 BT keyboard when nothing else worked
open Terminal
and then Copy & Paste the next Steps in the Terminal
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
It takes awhile for the install to complete. Once done, type the following command in terminal:
brew install blueutil
Once the brew utility “blueutil” is installed, put your bluetooth keyboard in discovery mode and then enter the following command in terminal:
brew blueutil --inquiry
This will obtain a verbose output that contains the MAC address of the keyboard. It is the sequence of six pairs of alphanumeric pairs separated by hyphens in the form xx-xx-xx-xx-xx-xx. Somewhere in the output you will see a string of four zeroes preceded by a “+” sign “: +0000. If your keyboard inquiry produced a different string. Use your string instead of “0000” in the following.
While the keyboard is in discovery mode, enter the following command in terminal:
blueutil --pair xx.xx.xx.xx.xx.xx 0000
Note: Use your keyboard’s MAC address and the sting of digits immediately after the”+” character from your inquiry output.
Then (after 5-10 seconds), type 0000 on the numbers above the alphabetical keyboard and hit the “Return” button (do not use the numeric keypad).
That will pair your keyboard, but not connect it
To connect it, Click the Bluetooth icon on your status bar and right-click on the keyboard device that is now shown on the Paired device list. Select “Connect” from the pop-up menu.
This sequence forces the bluetooth module on your Mac to accept 0000 as the PIN code for pairing instead of a random pin that the module generates but fails to present via the GUI