To add to cityzen's, if you see some of dust or gunk in there from food, finger grease, etc. give it a few shot of canned air. And, while powered down clean up any sticky stuff with a q-tip and some rubbing alcohol.
"Note that the spacebar has four metal brackets/bars. The inner two can stay in the key itself. But the ends of the outer two must hook underneath four little clasps that are on the base of the keyboard. If not, the far ends won't work (underneath the C and M keys).
So if you see all four metal brackets when you pull off the spacebar, gently take off the outer two and hook them into the clasps on the computer itself. Then line everything up and snap it together."
"This was the info I was searching for but alas to late:
How to reattach a Spacebar Key to the Magic Keyboard
I had ruined the latches. You have to be careful check out step 2 as it matters what is “up” and what is “down”. On the “down” side there are a couple of notches that need to fall into place."