Here's a derivation that has nothing to do with relativity!
Imagine a person who can swim in still water with speed c but who is swimming in a river with a downstream current of v. If he swims a distance downstream a distance l, his speed, relative to the bank (oops! a little relativity there!) is c+ v and so he take time \frac{l}{c+v}.
He now turns and swims the same distance upstream: now his speed, relative to the bank is c- v (of course, we must have v< c for that to be possible) and so the time required is \frac{l}{c-v}. The time required for the "round trip" is the sum of those: \frac{l}{c+v}+ \frac{l}{c-v}= \frac{lc-lv+lc+lv}{c^2- v^2}= \frac{2lc}{c^2- v^2}.
Now, he swims a distance l' ACROSS the river. Of course, in order to go directly across the river, he must swim slightly up stream. Drawing a triangle, it is easy to see that his "speed made good" is \sqrt{c^2- v^2} and so the time to go l' and back is \frac{2l'}{sqrt{c^2- v^2}}.
Suppose he finds that the two times are exactly the same? What must the relationship be between l and l'? Setting the times equal,
\frac{2lc}{c^2- v^2}= \frac{2l'}{sqrt{c^2- v^2}} so that
l'= \frac{cl}{\sqrt{c^2- v^2}}= \frac{l}{\sqrt{1-\frac{v}{c}^2}}.
Do you see the connection? The Michaelson- Morely experiment which was supposed to measure the effect of the Earth's movement through the "ether" gave a null result. Although the two arms of the "supposed" to be of the same length, Lorentz calculated how much the one pointing "upstream" must have contracted in order to give the same time for the path of the light.
Actually, Lorentz did come up with a theory to explain that: What if, as a result of the fact that magnetic force is dependent upon speed (which is what really opened that whole can of worms to start with!) caused electrons to exert more force in the direction of movement so that the arm facing in the direction of movement contracted exactly enough to give a null experiment! That's lovely! That's exactly how a lot of things happen in science! Unfortunately (for Lorentz anyway) a variation on the Michaelson-Morley experiment (called, I think, the "Kennedy" experiment) showed that that was not the case, leading Einstein to conjecture that it was space itself (the space between the electrons themselves) that contracted.