I have had the same problem with a Surface Pro 4. Issue started after an update. I have tried all the fixes online I could find and none have worked. Sure I can get the keyboard to come back, but after sleep or restart it will stop again. I was getting used to just physically disconnected and reconnecting the keyboard to bring it back waiting on an eventual MS fix.
Despite the 'updates' being totally up to date, I was able to get the UEFI to download an update from Device Manager, but still no change to the problem.
However something I have noticed that is not mentioned in this thread that in Device Manager, when the keyboard is not being detected, the soft cover driver is missing under Keyboard. I then go to View/show hidden devices and of course the driver is still there. I select scan for hardware changes and the keyboard starts working and the driver is now live....until next restart of course.
So does this narrow the issue down at all that really its this 'detection' thats at fault as opposed to the drivers and everything else.
What happens for you when trying this?