What could be causing the user interface to freeze? Recently, the user interface of my Mac Mini started to freeze. I can move the mouse, but mouse clicks don't have any effect: I cannot select a different window, right-click on  the desktop doesn't open any contextual menu, and the menus on the top bar are not opened.

All I can do is clicking the shut-down button, but I have to press it twice: The first time I press it (and keep it pressed), I hear a "click!" noise I thought produced from the external hard disk; the second time I press it, the computer shuts down.

What could be causing this issue? How can I find the cause?

The first two times it happened, I thought it was Spotlight causing it, but the last time it happened, Spotlight was not indexing the hard disk's content.
Could be anything, unfortunately.  Is the mini in a well-ventilated area?  Could be overheating.  The hard drive could be dying.  Could just be a corrupted OS install.  You'll have to start trying things to eliminate possibilities.  (eg: install OS an external drive, boot from that drive, see if it still hangs.)