In addition to the future benefits of the trade, which have been obvious, it was not at all unreasonable for the Brewers front office to believe that Rogers could fill in just fine for the rest of the season. Sure, you lose a great closer (who was struggling mightily), but there was every reason to think that Williams could step in as the closer and Rogers could be a solid bullpen arm. The former was correct, the latter unfortunately did not work out.
The front office made a tough decision. They knew they couldn't/wouldn't pay Hader what he'd want, but they also knew he was integral to the team's success. They decided to get as much as they could for him, since they wouldn't get anything after the season. Didn't work out well that season (but as others have said, the team was scuffling before the trade, too), but has so far been incredible since.
Not every move works out. This one had mixed results, but the benefits have outweighed the negatives.