The real answer is: it doesn't really. Or rather: we can still extract some physics out of it! Lets derive $$ S[\phi] = \int d^d x \mathcal{L}[\phi,\partial\phi]\ \delta S[\phi] = \int d^dx \delta \mathcal{L} = \int d^dx \left( \frac{\partial\mathcal{L}}{\partial \phi} \delta \phi + \frac{\partial\mathcal{L}}{\partial \partial_\mu\phi} \delta (\partial_\mu\phi) \right) $$ we first use that $\delta$ and $\partial$ commute and then <PERSON> rule to get $$ = \int d^dx \left( \frac{\partial\mathcal{L}}{\partial \phi} \delta \phi + \frac{\partial\mathcal{L}}{\partial \partial_\mu\phi} \partial_\mu(\delta \phi) \right)\ = \int d^dx \left( \frac{\partial\mathcal{L}}{\partial \phi} \delta \phi + \partial_\mu \left( \frac{\partial\mathcal{L}}{\partial \partial_\mu\phi} \delta \phi \right) - \partial_\mu \left( \frac{\partial\mathcal{L}}{\partial \partial_\mu\phi}\right) \delta \phi \right)\ = \int d^dx \left( \underbrace{\left( \frac{\partial\mathcal{L}}{\partial \phi} - \partial_\mu \left( \frac{\partial\mathcal{L}}{\partial \partial_\mu\phi}\right) \right)}\text{EoM = 0} \delta \phi + \partial\mu \left( \frac{\partial\mathcal{L}}{\partial \partial_\mu\phi} \delta \phi \right) \right) = 0\ $$ So we are left with $$ \delta S [\phi] = \int_{\mathbb{R}^n} d^d x \partial_\mu \left( \frac{\partial\mathcal{L}}{\partial \partial_\mu\phi} \delta \phi \right) = 0 \ $$ There are 2 ways this can be $0$.
* First we see that by stokes we get the GLOBAL statement $$ \delta S [\phi] = \int d \left( \frac{\partial\mathcal{L}}{\partial \partial_\mu\phi} \delta \phi \right) = \left.\frac{\partial\mathcal{L}}{\partial \partial_\mu\phi} \delta \phi \right|_{\partial \mathbb{R}^n} =0 \ $$ where we usually assume all fields vanish at $\partial \mathbb{R}^n$, i.e. 818
at infinity.
* Another way to get $\delta S = 0$ (and in a sense a more physical and mathematically rigorous way) is to demand the LOCAL statement $ \partial_\mu \left( \frac{\partial\mathcal{L}}{\partial \partial_\mu\phi} \delta \phi \right) = 0$. This is exactly the conserved current demand: $\partial_\mu j^\mu = 0$. So we find that $$ j^\mu = \frac{\partial\mathcal{L}}{\partial \partial_\mu\phi} \delta \phi $$ is the conserved current associated with variation $\delta\phi$. 9