As spotted by iMore, this indemnification stems from how Epic Games breached the developer agreement it had with Apple when it tried offering its own alternative payment system in August 2020.
In short: Epic Games pissed off the court when it consciously chose to violate the terms of its its contract with Apple before filing the lawsuit, rather than first filing the lawsuit and waiting for it to conclude. The court is taking the unusual step of billing Epic Games for Apple’s legal expenses precisely to disincentivize this kind of behavior in the future.
Quoth the article:
In short: Epic Games pissed off the court when it consciously chose to violate the terms of its its contract with Apple before filing the lawsuit, rather than first filing the lawsuit and waiting for it to conclude. The court is taking the unusual step of billing Epic Games for Apple’s legal expenses precisely to disincentivize this kind of behavior in the future.