Short codes only pay off when frequencies are uneven
If four letters A, B, C and D each make up a quarter of the text, writing every letter as two binary digits is already as short as it gets, and it won't compress. Now say A makes up half, B a quarter, and C and D an eighth each. Code A as 0, B as 10, C as 110 and D as 111. Multiply each letter's number of digits by how often it appears and add them up, and you get the average code length:
21×1+41×2+81×3+81×3=1.75
Half the letters take just 1 digit, and only a quarter take 3, so each letter averages 1.75 digits. A hundred letters take 25 digits fewer than writing two digits each. Write the common ones short and the rare ones long, and the total length comes down.
This code can be built with Huffman's method. First join C and D, the rarest, into a group. That group makes up a quarter, so join it with B, which is also a quarter, and finally join that with A. Every time two groups are joined, one more 0 or 1 is needed to tell them apart, so every letter in the group gets one more digit in its code. C and D, joined first, are the longest; A, joined last, has just one digit. The extra digits all land on the rarest letters.
Count the rule and the exceptions together
A thousand characters are all A, except the 500th, which is B. Writing "A repeated a thousand times, with the 500th changed to B" takes only a dozen or so words. If three hundred Bs are scattered through the thousand characters, you have to list all three hundred positions one by one. That list of exceptions is longer than the original, so the rule was a waste of space. To judge whether you've found a pattern, check whether the rule plus the exceptions is shorter than just copying out the original.
Being able to compress shows you understand
Copying down the sunrise time for every day of a year takes 365 lines. If you understand how the Earth turns, a few numbers let you work out any day. Both records are equally complete. The difference is that the short one isn't copied, it's worked out: it can also work out any day next year, while the copied table can't work out a single line. Being able to compress shows you've found the rule that produces the data, and that rule can also produce data you haven't seen yet.
Data with lots of repetition, a lopsided spread, or values that depend on what came before compresses best. A record of coin tosses won't compress, because there was never a pattern in it. Nor can a lossless method make every input shorter. There are so many possible strings of a thousand digits that there aren't enough shorter strings to go around, so two inputs must end up as the same short string, and when you decompress you can't tell them apart. Lossy compression means deciding first what to throw away: delete a rare fault from an incident report, and the report gets shorter, but whoever investigates loses the clue.