I don't know Lua, but I think it's fairly self-explanatory. The commenting is good enough to get me through, anyway.
It adds a hook for the console, which I guess is the chatbox in-game. I have no idea what the second parameter does, but I'll guess that it's not too important if it's an empty string. The third parameter should be a callback.
I don't know why "i" is there, as it isn't used, but "s" seems to be the string that is to be echoed. The callback function checks for an "=" in the string, rather loosely ensuring that it is actually supposed to perform whatever operations it performs with the string.
Then it makes sure that the string ends with a semicolon; if it doesn't, it appends one. I'm not sure what the gsub function does, but I'll hazard a guess at some sort of pattern replacing function. The comment says that it gets rid of spaces, so I'll believe it.
"for k, v in ..." seems much the same as PHP's "foreach (... as $k => $v)", and the gmatch function looks like it iterates through the string s to find k=v pairs, delimited by a semicolon. That looks similar to a RegEx, but I don't know what the "%" does. Possibly the same as a backslash in a RegEx.
_G looks like PHP's $GLOBALS array, which contains a reference to all variables in the global scope. Setting _G[k] to v would be the same as setting the value of k to v. That probably doesn't make sense, so pretend "k" is set to "foo".
_G[k] = "bar" would be the same as foo = "bar".
Then a line is echo()'d to somewhere, probably the chatbox, to tell the user what's going on.
Returning a value of 1 seems to prevent the line that you have echo()'d with the command "/echo" from showing up in the chatbox.
There's a lot of uncertainty in the above, but I think that's the general idea of it. I'll attempt to learn a little bit of Lua sometime in the future and correct any mistakes.