Prince William was given the keys to the city of Rio de Janeiro as he begins a five-day visit to Brazil to stage his annual Earthshot Prize ceremony.