From the Super Mario Wiki
The Key is an item in the PC release of Mario's Time Machine. It is a standard house key (belonging to Benjamin Loxley) that was used by Benjamin Franklin during his kite experiment in 1752, allowing him to look into the nature of electricity and lightning. However, before he could complete the experiment, the Key is stolen by Bowser after he travels back in time to 1752. It is then exhibited in his museum alongside all of his other stolen artifacts. It is then taken by Mario after he enters the museum, at which point he travels back in time himself to Philadelphia circa 1752 to return it. As he does not know that the Key belongs to Franklin, he asks various people within Philadelphia about the surroundings until he absolutely confirms the owner's identity. Mario then brings it to Franklin, who is already outside while flying a kite during a thunderstorm, and gives it to him. Franklin thanks Mario and immediately attaches it to the string of the kite.