Why change of variables in the Hamiltonian give us the same physics while changes of variables in the Lagrangian does not? Suppose we have the Lagrangian density
$$L=\partial_\mu\phi\partial^\mu\phi-m^2\phi^2\tag 1$$
With  $\phi$ a scalar field and  $\pi=\frac{\partial L}{\partial \dot{\phi}}=2\dot{\phi}$ we can show that the Hamiltonian density  $H$ is given by
$$H=\pi+\nabla \phi \cdot \nabla \phi+m^{2} \phi^2 \tag 2$$
Now suppose we make a change of variables $$\phi=\sin \eta \tag 3$$ we obtain
$$L(\phi)=L'(\eta)=\partial_\mu\eta\partial^\mu\eta\cos^2\eta-m^2\sin^2\eta$$
From $L'(\eta)$ we can construct the another Hamiltonian density
$$H'=\pi'+ \nabla\eta\cdot\nabla\eta\cos^2\eta+m^2\sin^2\eta \tag 4$$
where $\pi'=2\dot{\eta}\sin^2\eta$
Now if we make the substitution $(3)$ in $(2)$ we obtain
$$H(\phi)=H''(\eta)=\pi+ \nabla\eta\cdot\nabla\eta\cos^2\eta+m^2\sin^2\eta \tag 5$$
Comparing $(4)$ and $(5)$ we see that $H'\neq H''$
Now the evolution of states in the Schrodinger picture
$|\psi(t)\rangle=U\left(t\right)\left|\psi\left(0\right)\right\rangle$
Where
$$U(t)=\mathrm{T} \exp \left(-\frac{i}{\hbar} \int_{0}^{t} H\left(t^{\prime}\right) d t^{\prime}\right)$$
So probability amplitudes using $H'$ and $H=H''$ will give different results.
My question is why change of variables in the Hamiltonian give us the same physics while changes of variables in the Lagrangian does not?
 A: Your Legendre transformation isn't right.  Given some Lagrangian density $\mathscr L(\phi,\dot \phi, \nabla \phi)$, the canonical momentum is $\pi := \frac{\partial \mathscr L}{\partial \dot \phi}$ and the Hamiltonian density is $\mathscr H = \pi \dot \phi -\mathscr L$.  In your first example, you should have
$$\mathscr H(\pi,\phi, \nabla \phi) = \frac{\pi^2}{4} + (\nabla \phi)^2 + m^2 \phi^2, \qquad \pi = 2\dot \phi$$
After the transformation $\phi = \sin(\eta)$ in the Lagrangian and performing the Legendre transformation, the Hamiltonian density becomes
$$\tilde{\mathscr H}(\tilde \pi,\eta,\nabla \eta) = \frac{\tilde \pi^2}{4\cos^2(\eta)}+ (\nabla \eta)^2\cos^2(\eta) + m^2\sin^2(\eta), \qquad \tilde \pi = 2\cos^2(\eta) \dot \eta$$
Inserting $\phi = \sin(\eta)$ into the expressions for $\pi$ and $\mathscr H(\pi,\phi,\nabla\phi)$ reproduces the expressions for $\tilde \pi$ and $\tilde {\mathscr H}(\tilde \pi,\eta,\nabla \eta)$.
A: Suppose a Lagrangian gives the correct physical model, while after a particular change of variables it no longer does. Thus the two forms of the Lagrangian contradict each other. This must mean that the variable change was incorrectly executed.
A a side note: usually this Lagrangian carries a factor of 1/2. This will avoid cluttering expressions unnecessarily. Also in your Hamiltonians you should write $\pi^2$, $\pi'^2$ etc.
