EDIT: I realised how your solution was working - amended to reflect this.
FREQUENCY is searching for entries from your bins in the search array. Here's how it's working:
Search array: 1 2 3 4 1 2 7 3
Bins: 1 2 3 4 1 2 7 3
Bin 1 => there are two 1's => 2
Bin 2 => there are two 2's => 2
Bin 3 => there are two 3's => 2
Bin 4 => there is one 4 => 1
Bin 1 repeated => 1 already counted => 0
Bin 2 repeated => 2 already counted => 0
Bin 7 => there is one 7 => 1
Bin 3 repeated => 3 already counted => 0
It almost seems that the solution is exploiting a FREQUENCY quirk, that is, it won't count the same bin twice, because you might expect the second bin with value 1 to be non-zero as well. But that's how it works -- as it will only count the number of occurrences for the first bin and not a duplicate bin, the number of rows with a value greater than zero will give you the number of distinct entries.
Here's an alternative approach which you might find useful. it can be used to calculate the number of distinct values:
Suppose your string range is B2:B10. Fill down in another column
=(MATCH(B2,B$2:B2,1)-(ROW(B2)-ROW(B$2)))>0
The row should change as you copy down, so the second row should be, for example:
=(MATCH(B3,B$2:B3,1)-(ROW(B3)-ROW(B$2)))>0
This is signalling TRUE if the current row contains the first instance of a string (if you give it a couple of minutes you should be able to work out what it's doing). Therefore, if you count the number of TRUEs with COUNTIF() then you should get the number of distinct strings.