<p>We have a CustomAction that sets some registry key HKEY LOCAL_MACHINE. This wasn't working on Vista with UAC, until we made the action "deferred". The installer worked in other cases. Anyone knows why?</p>

<p>We are using WIX to create the installer.</p>

Your custom action was being run immediately when it was encountered in the InstallExecuteSequence; instead of when the actual install script was being executed.  This caused your custom action to be executed with the users permissions rather than with the system's elevated permissions.  This series of blog posts will explain in detail what is happening,
http://blogs.msdn.com/rflaming/archive/2006/09/23/768146.aspx
.  You shouldn't have custom actions that effect the state of the machine that do not run as deferred custom actions.