From the Super Mario Wiki
The Bosun's Pipe (which is also known as a boatswain's call) is an item in the SNES and PC releases of Mario's Time Machine. It is a small whistle used by boatswains to issue commands on a naval ship. In Mario's Time Machine, Mario receives it from a handmaiden of Queen Elizabeth I after he says that he needs to speak to the queen. As a proof of trust, she gives him the pipe and tells him to see Francis Drake, who is not willing to listen to Mario if he does not receive proof of Mario's loyalty. Once Mario gives him the Bosun's Pipe, he recognizes it as being from the handmaiden and talks to Mario about the Queen.