The RecursiveDirectoryIterator
is a class implementing the RecursiveIterator
interface.
The RecursiveIteratorIterator
is a class implementing the Iterator
interface.
With a foreach
traversal over it, it will take an object implementing RecursiveIterator
and do a recursive traversal (tree traversal) on it, here in PHP not only rewinding, fetching current, advancing next and checking validity but also checking if children exists and then internally iterating over these children, too.

So the RecursiveIteratorItertor
is providing object traversal in linear order while performing a tree traversal over a concrete RecursiveIterator
implementaion.
So the RecursiveDirectoryIterator
is only the container. You can iterate over it straight away (e.g. with foreach), but that linear order object iteration would not do the tree traversal.
That is why the RecursiveIteratorIterator
is there, it offers that tree traversal.
Which is exactly your case: Direct iteration over RecursiveDirectoryIterator
only does linear object traversal. Only the RecursiveIteratorIterator
knows how to do tree traversal on objects implementing the RecursiveIterator
interface. As it implements the Iterator
interface itself, it is then possible to do linear object traversal over the tree traversal.
See as well my answer to How does RecursiveIteratorIterator works in php, it covers the directory iterators exemplary to show the different modes of tree traversal that are possible.