Why does frequency encoding work?
Check this post.


  In the cases where the frequency is related somewhat with the target variable, it helps the model to understand and assign the weight in direct and inverse proportion, depending on the nature of the data.


Check also this thread.


  What's the rationale behind it?


High cardinality may result in dimensionality curse and actually decrease the quality of your model.