I'm asking why the court is involved still. I'm asking why the executive needs to get permission to do what the law allows. i'm asking where in the law there are boundaries, as you stated there are.
No one told the executive they need permission to add the question. I'm not sure where you keep getting this from.
The court specifically held that the Commerce Dept. didn't violate the law by adding the question. The court (SCOTUS) simply found that a district court's ruling to remand the case back to the Commerce Dept. for better rationale (because Ross' explanation doesn't match the evidence) is warranted.
https://www.supremecourt.gov/opinions/18pdf/18-966_bq7c.pdf
Boundaries can be defined in case law. Not just the law itself.
However, the opinion mentions a few boundaries. One being the Administrative Procedures Act that
embodies a 'basic presumption of judicial review,' and instructs reviewing courts to set aside agency action that is “arbitrary, capricious, an abuse of discretion, or otherwise not in accordance with law,”
Second, the opinion points out that:
The Census Act confers broad authority on the Secretary, but it does not leave his discretion unbounded.
The govt. argued that 5 U. S. C. §706(2)(A) prevents a judicial review “to the extent that” the agency action is “committed to agency discretion by law,”. The court disagreed because the 706(2)(A) exception is limited to administrative decisions that courts have said are up to agency discretion.
Since the census itself is not an agency discretion and since the Census Act doesn't provide a way to judge Ross' actions outside of judicial review, that's what they did. In order for it to be a meaningful judicial review, an agency must "diclose the basis" of their action. Case law states that this judicial review may look at “the mental processes of administrative decisionmakers” upon a “strong showing of bad faith or improper behavior”.
SCOTUS then basically said "look, we know some people will have their policy preferences when comign into office and will try and find ways to make it look legit, but Ross' decision doesn't match the rationale."