The third bracket is for passing the argument. I'll break it down into individual steps, so to make it (hopefully) clearer:
Code:
local a = 1
local f = loadstring("return function(x) local b=x+1 print(b) end") -- step 1
local g = f( ) -- step 2
g(a) -- step 3
At step 1, loadstr returns a function whose body is the string it receives as argument. In this case this is equivalent to writing:
Code:
local function f( ) return function(x) local b=x+1 print(b) end
Note that loadstring just returns a function, but it doesn't execute it. This function (f), when executed (step 2), returns another function that accepts an argument. Here I called it 'x' instead of 'a' to make clear that it is the argument, not (yet) the local variable 'a'. Step 2 thus ends up being equivalent to writing:
Code:
local function g(x) local b=x+1 print(b) end
Finally, at step 3 we execute the function g passing it 'a' as argument (thus x=a).
The original example is obtained by merging the three steps into one.
BTW, you can do it in another way which is arguably simpler, but I don't know if it works in Lua 5.1:
Code:
local a = 1
loadstring("local a=({...})[1] local b=a+1 print(b)")(a)
EDIT: fixed the last code snippet