UTF-8 is "ASCII-friendly", in the sense that a text file consisting only of ASCII characters will be exactly the same, whether it is encoded with ASCII or UTF-8.
Note: some people think there are 256 ASCII characters. There are only 128. The ISO-8859-x is a family of encodings whose first 128 characters are ASCII and the rest are other characters.
Also, UTF-8 is very well-designed, and gives you several properties, for instance, some characters are encoded with 1 byte, some with 2, 3, or 4 - but a 4-byte character will never contain the bytes of any shorter character, and nor will a 3 or 2 byte character. All 1-byte characters are encoded with bytes 0 to 127, while all longer characters are encoded as a sequence of bytes in the range 128 to 255.
A non-UTF-8 byte stream (for instance, a binary file, or a UTF-16 file) usually can be ruled out as UTF-8, because it is likely to violate such properties. The only exception is plain ASCII files which of course can be harmlessly interpreted as UTF-8 anyway.
So in short, UTF-8 files can be detected as such because most "random" byte sequences are illegal in UTF-8, and so something that doesn't violate any rules is quite likely to be UTF-8.