It is not very complex matter, but it is not easy to explain shortly if you are not acquainted with analytic geometry
Shortly speaking, if we define some points (or objects as set of points) in 3D space, we can then perform some manipulations with them:
- rotation around arbitrary axis;
- movement in arbitrary direction;
- shrinking and stretching;
All these are performed with simple enough math operations on the set of points.
Besides them there are also operation of projection (for example 3D space to 2D).
So what happens to star field is the movement in z direction and projection to the imaginary plane between user and the stars - this imaginary plane is then simply rendered to screen.
Dividing x and y by z is not the completely correct transformation, but it is good enough approximation for effect of flying through stars.
If you really want to dive deeper in this topic, it would be good to lay your hands on some book or tutorial on basics of analytic geometry in 2D and then in 3D (they can often be found hand by hand with books on linear algebra) and do some practical tasks - like rotating squares and other objects on the screen etc.
Do not be afraid of horrible titles of these branches - they really involve only arithmetic and bit of trigonometry.