See the brew.sh homepage.

This will request your password as it needs root permissions.

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

See install.sh on GitHub.

If upgrading Homebrew, it is recommended to then upgrade all packages.