Open System Preferences > Bluetooth
Select: Show Bluetooth in menu bar
Try deleting the associated Bluetooth preference file, then try re pairing the keyboard. Preference files can become corrupted.
Open a Finder window. From the menu bar top of your screen click Go > Go to Folder
Type of copy paste the following:
Click Go then move the com.apple.Bluetooth.plist file to the Trash.
Restart your Mac. Try pairing the keyboard.