The idea of a lens is to have a linear relationship between the distance a ray passes through off axis, and the amount the ray is kinked on passing through. Let us call the former quantity [itex]r[/itex] and the latter [itex]\Delta\theta[/itex]. The proportionality constant is [itex]f[/itex], the focal length. So we have
[tex]r=f\Delta\theta[/tex]
If a ray comes from a point on axis a distance [itex]o[/itex] upstream of the lens, and if [itex]\theta_o[/itex] is the angle, then for small angles, [itex]\theta_o=r/o[/itex].
If this ray comes to a point on axis a distance [itex]i[/itex] downstream of the lens, and if [itex]\theta_i[/itex] is the angle, then for small angles, [itex]\theta_i=r/i[/itex].
Now, realize that
[tex]\Delta\theta=\theta_o+\theta_i[/tex]
and you have your formula.