I don’t know about legal but there definitely isn’t a way to watch live F1 in HD illegally, sites that claim to do so are lying.
There are some subscription services that cater for people in countries that don’t have tv coverage. Personally, being in the UK, I think the only option I have is to buy a Sky subscription and use their streaming service.
Wikipedia might have the answers for you, scroll down to ‘2017 TV broadcasters’ and ‘Official internet broadcasters’
https://en.wikipedia.org/wiki/List_of_Formula_One_broadcasters