It is gross malpractice that things like this are presented dogmatically rather than honestly in schools. It results from laws requiring everyone to be taught mathematics whether they want to or not. Consequently only that which everyone can be forced to do is taught.
The pigeonhole principle is involved here. That says if you put seven objects into six boxes, at least one box gets more than one object. Consider the rational number $7/26$. Let's find its decimal expansion by long division:
$$
\begin{array}{cccccccccccccccccccc}
& & 0 & . & 2 & 6 & 9 & 2 & 3 & 0 & 7 & \\ \\
26 & ) & 7 & . & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
& & 5 & & 2 \\ \\
& & 1 & & 8 & 0 & & & & & & & \longleftarrow\\
& & 1 & & 5 & 6 \\ \\
& & & & 2 & 4 & 0 \\
& & & & 2 & 3 & 4 \\ \\
& & & & & & 6 & 0 \\
& & & & & & 5 & 2 \\ \\
& & & & & & & 8 & 0 \\
& & & & & & & 7 & 8 \\ \\
& & & & & & & & 2 & 0 \\
& & & & & & & & & 0 \\ \\
& & & & & & & & 2 & 0 & 0 \\
& & & & & & & & 1 & 8 & 2 \\ \\
& & & & & & & & & 1 & 8 & 0 & \longleftarrow & \text{repetition}
\end{array}
$$
The remainder $18$ has been repeated.
There are just $26$ possible remainders: $0,1,2,3,4,\ldots,25$.
If $0$ occurs as a remainder, the decimal expansion terminates.
If $0$ never occurs then there are $25$ possibilities. By the pigeonhole principle, the process cannot go $26$ steps without a repitition. Once a repetition occurs, we're just doing the same problem again, and must get the same answer.
Thus every rational number has a terminating or repeating expansion.
There is also an algorithm for converting this repeating decimal back to the fraction it came from, $7/26$.