The fact that the second key works just fine definitely rules out a lot of stuff.
I agree with andewwynn that it's not just coincidence - most likely the opening up, etc. restored whatever flaky connections are in there, and now they've opened up again.
I would measure the battery voltage when you first open it up. If it's good, you know it is not the battery that is the problem. If it's low, then you need to keep that as an option, although it would point to the charging circuit in the key fob as where the problem is.
Also, I don't have this yet (one day ...), but if you just want to take care of the key fob charging with a different method, this looks good to me:
https://xoutpost.com/bmw-sav-forums/...w-key-fob.html