Considering $m_1$ and $m_2$ as a system, there is a net horizontal force $F$ acting on them so their centre of mass must accelerate with acceleration
$\displaystyle a_0 = \frac F {m_1+m_2}$
This is true regardless of whether or not $m_1$ moves relative to $m_2$.
The frictional force which opposes $m_1$ moving relative to $m_2$ has a maximum value of $\mu m_1 g$. If $F - \mu m_1 g \le m_1a_0$ then $m_1$ will not move relative to $m_2$ and both blocks will accelerate with acceleration $a_0$. Substituting the expression for $a_0$ above, we see that this condition becomes
$\displaystyle F - \mu m_1 g \le F \frac {m_1} {m_1+m_2}
\\ \displaystyle \Rightarrow F \frac {m_2} {m_1+m_2} \le \mu m_1 g
\\ \displaystyle \Rightarrow F \le \mu g (m_1+m_2) \frac {m_1}{m_2}$
In this case, the frictional force is
$\displaystyle F \frac {m_2} {m_1+m_2}$
and we can see that (by Newton's Third Law) this acts on $m_2$ to accelerate it with acceleration $a_0$ too. In effect, the force $F$ is divided between $m_1$ and $m_2$ in proportion to their masses, so that they both have the same acceleration.
On the other hand, if
$\displaystyle F > \mu g (m_1+m_2) \frac {m_1}{m_2}$
then the net force on $m_1$ is $F - \mu m_1 g$ so $m_1$ accelerate with acceleration
$\displaystyle a_1 = \frac F {m_1} - \mu g$
and the force on $m_2$ is $\mu m_1 g$ so $m_2$ accelerates with acceleratiion
$\displaystyle a_2 = \mu g \frac {m_1}{m_2}$
and we have
$\displaystyle a_1 > \mu g \frac {m_1+m_2}{m_2} - \mu g
\\ \displaystyle \Rightarrow a_1 > \mu g \frac {m_1}{m_2}
\\ \displaystyle \Rightarrow a_1 > a_2$
Also note that the acceleration of the centre of mass of the system is the weighted sum of $a_1$ and $a_2$ which is
$\displaystyle \frac {m_1a_1+m_2a_2} {m_1+m_2} = \frac {(F - \mu m_1 g) + \mu m_1 g} {m_1+m_2} = \frac {F} {m_1+m_2} = a_0$
as we expect.