c denotes your column
char_length(c)
returns the number of characters in the column
char_length(replace(c,'word1','word'))
If there is one occurrence of the string word1 in the column c, the length of the replace expression will be one less than the original column length, as we replace 5 characters with 4. As the replace function will replace all occurences the length will be decreased correspondingly.
char_length(c) - char_length(replace(c,'word1','word'))
so this code calculates the number of occurrences. Adding these calculatin for all search words and columns will give the total number of occurrences and since you wish to get the column with the most hits first, we need order it descendingly.