I assume that the analogous situation in classical mechanics is
the following. If you are describing the motion of an object, its
Hamiltonian looks one way if you treat your object as a
mass-point. However, if you start considering the object as a
rigid body and not a point, your model starts to include
description of the time-evolution of the body's center of mass and
the evolution of it's angular momentum. The situation you are
encountering seems to be analogous. Your first Hamiltonian
describes the motion of a charged particle treated as a charged
point. However, the addition of the second term includes
description of its magnetic moment, i.e. your charged particle is
considered as a dipole (or something that has a magnetic moment,
like a rotating charged sphere) rather than a point. So the
second, extended Hamiltonian describes the evolution of both the
position of the electron and the evolution of its magnetic moment.
I hope this explanation makes sense.
The factor $H_I$ has nothing to do with the electric potential
$\phi$. It has to do with the dynamics of the magnetic moment.
Here is how I see the "derivation" you seek. When describing classically your charged particle, say the electron, you think of it as follows: it is a
little magnetized segment, not a point. The center of the segment
is its center of mass. When describing the dynamics of this
magnetized segment, you would like to know where it is in space
and how it is oriented in space. Thus, to describe fully the
configuration of the segment, you want to know the position $x \in
\mathbb{R}^3$ of its center, where $x = (x_1, x_2, x_3)$ is a
vector in three space, and the orientation of its axis (which is
aligned with the segment and is oriented according to the magnetic
field of the segment) determined by a vector $\mu = (\mu_1, \mu_2,
\mu_3) \in \mathbb{R}^3$ in three space, so that the vector $\mu$
is aligned with the segment. The vector's orientation and length
are determined in accordance with the segment's own magnetic field.
Now, you want to know how $x = x(t)$ and $\mu = \mu(t)$ evolve in
time under external static (i.e. time independent) magnetic field,
given by a magnetic vector potential $$A = A(x) = \big(A_1(x),
A_2(x), A_3(x)\big)$$ Observe that the magnetic field doesn't
change with time (hence static), so $\phi \equiv 0$. However, the magnetic field
could be inhomogeneous in space, i.e. it may vary from point to point. The vector field of the external magnetic field is
determined by $B = B(x) = \nabla \times A(x)$. As it is usually
the case in classical dynamics, in order to track the time
evolution of your object's configuration $x(t), \, \mu(t)$, you
have to track, in the Lagrangian picture, the time evolution of
the quantities $x(t),\, v(t), \, \mu(t)$ where $v(t) =
\frac{dx}{dt}(t)$ is the velocity of $x(t)$. In the Hamiltonian
picture, you have to track $x(t),\, p(t), \, \mu(t)$ where $p(t)$
is the conjugate momentum of $x$ and carries more or less the same
information as the velocity $v$. The Lagrangian and the
Hamiltonian functions consist of the terms that determine the
dynamics of $x, p$ plus the terms that determine the dynamics of
the magnetic moment $\mu$. Thus, the Lagraingian for $x, v$ is
$$L_0(x,\dot{x})=\frac{1}{2} \, m {v}^2+
{q}\, {A}(x) \cdot v = \frac{1}{2} \, m {\dot{x}}^2+ {q}\, {A}(x)
\cdot \dot{x}$$ where $v = \dot{x} = \frac{dx}{dt}$. The
Lagrangian term responsible for the time evolution of the magnetic
moment $\mu$ is the magnetic potential energy $$U = U(x, \mu) = -
\, B(x) \cdot \mu$$ In these notations $ \, \cdot \,$ is the dot
product of the three dimensional space $\mathbb{R}^3$ and $v^2 = v
\cdot v$. To form the total Lagrangian, we need to subtract the
potential energy $U$ from the rest of the lagrangian $L_0$,
obtaining the full lagrangian that determines the time evolution
of the position $x$, the velocity $\dot{x}$ and the magnetic
moment $\mu$:
$$L = L_0 - U$$
$$L(x, \dot{x}, \mu) = L_0(x, \dot{x}) - U(x, \mu)$$
$$L(x, \dot{x}, \mu) =\frac{1}{2} \, m {v}^2+
{q}\, {A}(x) \cdot v + B(x)\cdot \mu$$ Analogously, in the
Hamiltonian picture, the Hamiltonian for $x, p$ is
$$H_0(x,p)=\frac{1}{2m} \big( p -
{q}\, {A}(x) \big)^2$$ The Hamiltonian term responsible for the
time evolution of the magnetic moment $\mu$ is the magnetic
potential energy $$H_I = U = U(x, \mu) = - \, B(x) \cdot \mu$$ To
form the total Hamiltonian, we add the potential energy $U$, i.e.
the magnetic moment potential Hamiltonian $H_I$, to the rest of
the Hamiltonian $H_0$, obtaining the full Hamiltonian $H$ that
determines the time evolution of the position $x$, the momentum
$p$ and the magnetic moment $\mu$:
$$H = H_0 + U$$
$$H(x, p, \mu) = H_0(x, p) + H_I(x, \mu) = H_0(x, p) + U(x, \mu)$$
$$H(x, p, \mu) =\frac{1}{2m} \big( p -
{q}\, {A}(x) \big)^2 - B(x)\cdot \mu$$ Consequently, the
evolution equations for $x, p, \mu$ are
\begin{align*}
\frac{dx}{dt} &= \frac{\partial H_0}{\partial p}(x,p)\\
\frac{dp}{dt} &= - \frac{\partial H_0}{\partial x}(x,p) -
\frac{\partial U}{\partial x}(x,\mu)\\
\frac{d\mu}{dt} &= \frac{\partial U}{\partial \mu}(x,\mu) \times
\mu = - \, B(x) \times \mu
\end{align*}
Observe the form of the third equation. It looks like that because
$\mu$ is a type of quantity very closely related to angular
momentum and its dynamics is driven by torques not by forces.
Double check all the signs (pluses and minuses), because I did not
check any of these derivations carefully, I simply derived them
off the top of my head, relying on general principle and
philosophy.
Finally, if you think about the magnetic potential $U = - \, B(x)
\cdot \mu$, it makes sense. Whenever the magnetic moment $\mu$ is
aligned with the magnetic vector field $B(x)$ the potential $U$
attains its minimum value, and if you look at the third equation,
you see that $B(x) \times \mu = 0$. Thus, no precession of $\mu$
will occur as long as $\mu$ is aligned with the magnetic field.
However, if $\mu$ is not aligned, the potential $U$ increases, and
precession starts to emerge because $B(x) \times \mu \neq 0$. In
the special case when $\mu$ is perpendicular to the magnetic
field, the potential $U=0$ which is its largest value, so the
precession of $\mu$ is the strongest.