You are right that the implementation of the Delete Hidden Layers command in the Actions palette is nonsense, just as the command itself (strictly speaking) because it also deletes objects and not just layers.
Currently, you'd indeed have to resort to creating a script for that task. I've created one that does delete empty, locked, hidden or non-printing main layers and sublayers. Currently it does not delete hidden objects. Let me know if that may help you and I'll post a download link.
As for your question: Why are so many of Illustrator's commands and menu items not actionable?
The answer is pretty simple and disappointing: It's because for many years Adobe has lost sight of implementing many commands as actionable commands.
About ten years ago, there was an official announcement indicating that the entire actions architecture was going to be revamped. Unfortunately, it was kicked into the long grass.
... View more