I mean a country is by definition sovereign, so the idea of 'legal precedent' is meaningless. You probably mean that it's not in keeping with the 'rules based global trading order' which is true, but that was/is simply a post-war construct that is getting pretty shaky these days. You're not supposed to be able to slap tariffs on whoever you feel like to strong arm them into doing your bidding either, but here we are.
Ultimately the government of India can fine Apple, or whoever they want, whatever they feel like if their voters don't kick up a fuss. I imagine that Apple has tried to appeal to the government and hasn't made any progress, so they're going for a constitutional ruling since this has authority over the legislature.
But I think Apple still has a lot of leverage here. They probably can't pull out of the country, though I imagine they could threaten it and see if the government calls their bluff. But they have large factory investments there (through Foxconn), people like their products, and I imagine lots of Indians work on products tied to the Apple ecosystem. Closing all of that out would not be good for the Indian economy. There is also wider leverage from the US government. I'm sure Tim Apple can find an even bigger piece of gold to gift to the administration.