Reset the PRAM:
Parameter RAM stores the configuration of your system. There may be something stored preventing the keyboard from being identified by the Keyboard preference panel.
Shut down your MacBook Pro. Press the power button, then before the grey screen comes up, hold down CMD + Option + P + R simultaneously until you hear the chime. Continue holding them until your MacBook Pro restarts, and you hear the chime again, then release.
You may also want to reset the SMC after trying other options. The method used varies by model. From the article linked below:
• Newer Macs with built-in batteries
Shut down the system and plug in the power adapter
Hold the Shift, Control, and Option keys on the left-side of your keyboard
Press the power button while these keys are held, and then release all keys at once
Start up the system normally
• Older portable Macs with removable batteries
Shut down the system and disconnect the power adapter
Remove the battery
Press the power button and hold it down for 5 seconds
Release the button, connect the power, and start up the system.
Apple does not recommend doing this often, however it can solve stubborn problems, especially with peripherals, and I've never seen any ill effects from it in the past 25 some-odd years of owning, using and abusing Mac portables, back when the SMC was a PMU.
If that does not work, try plugging the keyboard into either a USB extension cable or powered USB hub, which seems, oddly enough, to sometimes solve this problem.