With macOS, Apple automatically allows the menu bar to be hidden. In versions of macOS before Big Sur, the setting to turn this on or off is in General System Settings.
But in Big Sur, Apple has shifted the setting. It is now in the Dock & Menu Bar system setting. To set the menu bar to be hidden and displayed when you move the cursor to the top of the screen, select the check box.