The UNIX find command is recursive, and starting with the provided path, it will traverse all folders and files in the specified directory tree. When the find command matches a *.txt file, the full path to that file is passed into the {} so that the rm -f command has an explicit file to remove. This occurs until all returned matches are removed. The \; syntax terminates the -exec statement because one has to escape '\' a semi-colon from the shell itself.
I have been doing UNIX command line for 39 years and have lost touch with any current books on the subject. They are few and far between for macOS. You might have better luck over at unix.stackexchange.com, or stackoverflow.com. Enter the URL of either, and then a space followed by your short usage question in a browser:
unix.stackexchange.com find remove all text files from directory tree
You will get several focused hits on how to do this with find. Many of these hits may be using Linux, and not macOS, and you just have to be aware that some commands may seem to do the trick online, but when implemented in macOS, they may not work, or produce different results because of operating system, or command differences differences.
What you should learn is the Bash 3.5.2 syntax, because Apple has frozen on that version, or the more advanced Zsh shell, either of which are the shell from which you will use UNIX commands. Most of the Bash references found online are from Linux and Bash 4.n or 5.0 — which will not be suitable for macOS.