Just because the user doesn't need to pay up-front doesn't mean the service operates at a loss (YouTube pulled in $15 billion in 2019, according to a quick search). Furthermore, YouTube Premium is a paid offering. IMO Alphabet just uses YouTube as a playground for its ML experiments because it can moreso than because it needs to for viability.