Moraes essentially wanted a hostage. Executives of companies shouldn't be arrested for things they have no power over, such as content moderation. My guess is that Moraes wanted to force Musk's company to not have a legal representative in the country, because the moment you know if you accept a job there's a high chance that job will result in you being arrested, those business men and women won't want that job. So Moraes clearly forced a situation that drove X out of the country.
If anything – it would still have been incredibly draconian and abusive from Moraes part – but it would have been “less bad” if the had skip the whole "arresting the legal representative" thing and had went straight to "block Twitter/X for not complying with his orders" part. But I guess Moraes really wanted to go for the "they didn't have a representative in Brazil, so we ban it" narrative.
Which by the way, this requirement, even if it's in the law, it surely not demanded from the vast majority of online companies that offer their service in Brazil. Otherwise they would have blocked Blue Sky as well, because (I assume) it doesn't have legal representatives in the country. So at best this law is being selectively enforced.