Running r without arguments is equivalent to first executing !! (look up history substitution if this is news to you) which gives you the last command in your shell history, and then pressing the Enter key to actually execute the command (unless you disabled the requirement to confirm the command by pressing Enter before you execute it).
Example
Imagine running apt update (without sudo) only to be nagged about forgetting sudo. Then you could simply run sudo !! to prepend the previous command with sudo and not have to type apt update again. If you wanted to run sudo apt update for a second time, you could now simply execute !! because now sudo apt update would be the last command in your history.
Depending on your settings, you might have to press the Enter key after entering !! for confirmation before the command is executed. With r, you don’t have to.
Perhaps you already use the zsh add-on zsh-history-substring-search with which you could simply start typing pip and then press the Up arrow on your keyboard to find the last command that contains (and not necessarily starts with) pip.
The command r pip would skip over python3 -m pip install --upgrade black and immediately execute pip install --upgrade pip (without requiring a confirmation first).
With zsh-history-substring-search, by entering pip into the terminal and then pressing the Up or Down arrow key, you could cycle through both of these commands (because both contain the string pip) and then confirm your choice by pressing the Enter key.
You can simultaneously press the Control key and the r key on your keyboard to open what is known as the reverse incremental search. You can then begin typing your command (for example, pip install) and then use the Up and Down arrows on your keyboard to choose the wanted command from your history, and then confirm it by pressing Enter.
This, again, takes a few more keystrokes than using the command r if you’re absolutely sure you want to execute the latest matching command without needing to confirm it (for example, because you previously executed it just three seconds ago).
This command r exists only in zsh. If you want that command in bash too, you can recreate that command by defining the following alias:
aliasr='fc -e -'
Because you don’t need that alias when you’re using zsh, you can put the alias definition inside an if-construct to activate the alias only when you’re using bash: