Quantum unitary transformation In quantum mechanics, we know $\dot{\psi}=-\frac{i}{\hbar}H\psi$,
but why is $U\dot{\psi}=-\frac{i}{\hbar} \left(UHU^\dagger \right) U\psi$?
Does it mean $UHU^\dagger = H$ ? I think $UU^\dagger H = H$, but why can we change the order of the matrices here?
 A: You're overthinking this, assuming $U$ is unitary:
$$ U\dot\psi= -\frac{i}{\hbar} UH\psi=-\frac{i}{\hbar} UH\mathbb 1\psi= -\frac{i}{\hbar} UHU^\dagger U\psi.$$
$U$ need not be the time evolution operator and it need not commute with $H$ for this to work, it can be any unitary. This is just saying that if you write $\psi$ in another basis then it evolves with the Hamiltonian written in the new basis. (Or equivalently that a rotated vector evolves with the rotated Hamiltonian).
A: *

*If the Hamiltonian $\hat{H}$ does not depend on time, and $U$ is supposed to be the time-evolution operator, then $$\hat{U}~=~\exp\left(-\frac{i}{\hbar}\hat{H}\Delta t\right),\tag{A}$$
which commutes$^1$ with $\hat{H}$, so that $$UHU^{\dagger} ~=~ H,\tag{B}$$ cf. OP's question.


*If the Hamiltonian $\hat{H}$ do depend on time, then eqs. (A) & (B) need to be modified, cf. e.g. this Phys.SE post.
--
$^1$ A function $f(\hat{H})$ of $\hat{H}$ commutes with $\hat{H}$, cf. e.g. this & this Phys.SE posts.
A: user2723984 is correct. However, the 2nd part of your question is unresolved: if the Hamiltonian commutes with itself at different times, then the only operator in $U$ is $H$ and, as $H$ commutes with itself, the order of the operators may then be changed.
