Suppose you shot a large number of small classical magnetic dipoles with magnetic moment $\vec{\mu}$ through the field. Imagine the dipoles to be small enough that they could be treated as the particles of an ideal gas, and they are "boiled" out of some source into the magnetic field.
We would then expect each of the particle's components of velocity to be randomly distributed according to the Maxwell velocity distribution - because that is the classical result for an ideal gas. So the alignment of their magnetic moments would also start out random.
The dipoles would experience both a force and a torque from the magnetic field. The torque would cause them to rotate, and the force would, as you said, tend to line them up with the magnetic field, until they are in a minimum energy state. This alignment would take some time however, and, since they started out with random velocity and random orientation of their magnetic moment vector to the field, their final velocities once aligned would show some variation.
The key, though, that makes the motion of the particles vary AFTER they are aligned, is the nonuniform magnetic field. Suppose the field is in the z direction, and varies with z.
The particles are in a minimum potential energy state once aligned, with potential energy
$E=-\vec{\mu} \cdot\vec{B} = -\mu B $
But the magnetic field $B(z)$ varies with z, so the dipole still experiences a force
$\dfrac{\partial E}{\partial z} = F(z) = \mu\dfrac {\partial B(z)}{\partial z}$
So the classical dipoles, with randomly distributed magnetic moment orientations and velocities at start, would drift in varying directions, hit various positions on the detector.
But if the magnetic dipoles were somehow constrained to be on only two possible initial directions, you would expect to see a concentration of hits on two locations of the detector, and nothing anywhere else. They would start out with only two orientations with respect to the field and end up being deflected into only two concentrations on the detector. They'd have only two end states of "lining up" with the magnetic field, and then drift apart due to the nonuniform magnetic field.
So the Stern Gerlach experiment is evidence that the magnetic moment of electrons in atoms, and thus electron spin, is quantized, because the results resemble the second case above, not the first. The initial direction of the magnetic moment of the electron is limited by quantization of spin.