Work out 1÷3 and you get 0.333..., with the 3 repeating forever. But 1÷4 stops cleanly at 0.25. Follow the division step by step and you can see exactly why some fractions end and others repeat forever, and how long that repeating stretch (the repetend) turns out to be.
When you convert a fraction to a decimal, working through the division keeps producing a remainder. Once the remainder hits 0, the decimal ends right there (a terminating decimal); once the remainder becomes exactly equal to one you've already seen, the same digits keep repeating from then on (a repeating decimal) — since the only possible remainders are whole numbers smaller than the divisor, sooner or later it has no choice but to repeat or hit 0.
Pick a fraction and follow the long division one step at a time. The moment a remainder matches one from before, the same digits keep repeating from there on.
When a denominator is made up only of factors of 2 and 5, the decimal ends cleanly. Otherwise it's guaranteed to repeat, and the length of the repeating stretch (the repetend) is completely different for every denominator.
Going the other way, a repeating decimal can always be converted back into an exact fraction. Set it equal to x, multiply by 10 raised to the repetend's length, then subtract — and the repeating part vanishes.