Copying is a necessary and pervasive part of typical internet usage. Visiting any website requires, not only that it is temporarily copied and saved onto your hard drive, but also that every intermediate server through which the content is transmitted to you has a copy, and also that a copy can be displayed on the physical screen you use to view the media. This was the source of a lot of controversy in the early internet era, I recommend reading Chapter 3 of Lawrence Lessig's Free Culture if you're interested in the history.
Since the default is "any copying is illegal", I will answer the contrapositive "why isn't using my browser to visit YouTube illegal?". I claim that the Terms of Service of YouTube are irrelevant for the purposes of this question. I think there are essentially two defenses for using the website/app in its usual fashion, which do not apply to tools for downloading permanent copies.
Both rest on the distinction that the implied copying is (1) temporary, (2) non-commercial, (3) transient, (4) the minimum necessary to carry out the relevant technical aim (i.e. transmitting video content through the internet).
- In the US I claim that implicit copying would definitely be considered a fair use, while making a personal copy for private use could but probably wouldn't, and making a personal copy to distribute would definitely not. See https://law.stackexchange.com/a/3589/36772 for details.
- In the EU There are explicit exemptions in the Copyright Directive which permit copying under these circumstances. See https://law.stackexchange.com/a/4858/36772 for details.
One commenter mentions anti-circumvention law as in the DMCA. This might be relevant, but personally I doubt it, as YouTube does not use any kind of "digital lock" (i.e. DRM) that I'm aware of. Access to the raw blob is obfuscated, but not directly locked.
A final note is that in some jurisdictions you are allowed to make "Home copies" for personal use, or for other specific demarcated purposes. You can find some references to specific jurisdictions on the Wikipedia article for Private copying levy (which is a common form of tax used to remunerate copyright holders for private copying).
youtube-dl and Invidious
There are two relevant software projects that touch on this area.
- Invidious is an open-source front-end for YouTube. A certain amount of copying is incidental in the provision of such a service, but as far as I know it is considered likely to be legal. The developers certainly think so.
- youtube-dl is an open-source software project enabling users to download any youtube video they like. It is the user's responsibility to ensure that they are using youtube-dl under proper license of the downloaded material.
There have been many similar projects: Vanced, HookTube, Youtube2Peertube, ... which were intimidated into shutting down, either due to real or bogus legal threats. You may want to look into them if you want to know the details.