Short answer: usually yes, for personal use. Long answer below.
Copyright law in most Western jurisdictions recognises a concept called fair use (United States) or fair dealing (United Kingdom, Canada, Australia). Under these doctrines, making a personal, non-commercial copy of a work you have legitimate access to — for time-shifting, format-shifting, study, criticism, or research — is generally lawful. The 1984 Sony Betamax decision established time-shifting as fair use in the US, and that precedent has been cited for every subsequent home-recording technology from VHS to DVR to, yes, YouTube downloaders.
YouTube's Terms of Service prohibit downloading through any means other than YouTube Premium's offline feature. But terms of service are a private contract between you and Google, not criminal law. Breaking them can get your account suspended; it cannot get you arrested. The Electronic Frontier Foundation explicitly defended this position in 2020 when the RIAA tried (and failed) to take down youtube-dl from GitHub.
What is notlegal, anywhere, is redistributing copyrighted content you do not own. Downloading a music video to your phone to listen on a flight is fair use. Re-uploading that same video to your own channel for ad revenue is copyright infringement. Downloading a lecture to study for an exam is fair use. Selling a compiled DVD of that lecture series without the lecturer's permission is not.
For content under a Creative Commons licence, the rules are different and usually more permissive — many CC licences allow commercial reuse, remixing, and redistribution with attribution. YouTube marks CC videos in the description; check before you assume.
This is general information, not legal advice. If you have a specific commercial use case, talk to an actual lawyer in your jurisdiction.