GitHub reinstated the open-source tool YouTube-dl after taking the software down when the Recording Industry Association of America complained that it violated Section 1201 of the Digital Millennium Copyright Act.
However, the issue isn't totally black and white. If you violate the YouTube ToS, the company may terminate your account, as noted here: 'YouTube will terminate a user's access to the Service if, under appropriate circumstances, the user is determined to be a repeat infringer.'
If you want to download YouTube videos, the only way to do so responsibly is by paying the $11.99 for YouTube Premium.