Google makes enough money off Chrome and youtube they could afford to pay licensing fees so that end-users have a good experience. Software decoding vs hardware decoding is a massive difference in user experience.
Chrome is free and youtube notoriously doesn't make a profit (unless this changed in 2021).
Their money comes mostly from search.