Just for the record, when someone talks about occurrences they almost never mean combinations. As for how this works, it recursively builds a tree that breaks down the string, swaps elements, and recombines them to produce combinations.
When you have an algorithm you don't understand, the best approach is to either step through a small data set in a debugger or on paper and draw out what happens to the data. For example, you can get a good test run of this algorithm by typing "abc".
Don't expect someone to be around to explain everything to you, a good programmer's best weapon is the ability to disect code, trace through it, and methodically figure out how it works without any help.