It is data for an specific users, based on specified phone number, relating to an on going criminal case.
This is not a police investigation, but a court order, so there is at least enough evidence that there is a crime and who committed it to to warrant a criminal prosecution.
According to Brazilian law, law enforcement agencies can not request this kind of information without a court order and, to get that order, they have to show "just case", meaning evidence of authorship and materiality (that a crime really happened).
I don't agree with the prison order, which was disproportionate. But the request for data was legal and legitimate. Facebook is hiding behind the "the servers are not physically located in Brazil, so we don't have to comply" argument.