LagFix (fstrim), as is the full name of this geeky piece of software, is based on the Fstrim Linux tool, which has the same purpose. Basically, when the user is trying to execute a task, the LagFix app attempts to inform the device's memory controller about the free storage blocks that can be used to write data on at the current moment. Alternatively, in the typical case (which is when you don't have LagFix installed), the memory controller has to "ask" the system about the free storage blocks, and the whole system stops responding for a while (usually less than a second) until the memory controller gets its "answer". So that's how the tool is supposed to work, but will it really work for you? Well, you'll really have to try it on your specific device in order to be sure, but as it seems most of the users who have tried it are very pleased with the results they have achieved.
If you are experiencing problems with the lag, and wish to give LagFix a try, you can download it here!