It could be garbage collected if the scope of the variable was more precisely analyzed (not just "lexically" where you may want to reuse its value by adding code within that scope, but by effective area of use in that lexical scope).
Unfortunately, there's no tracking of the last use in the Lua compiler, scopes are only lexical and local variables reside in the table of local variables until the full table for the lexical scope is removed.
One way to avoid this is to unset the variable value explicitly in the Lua code (i.e. setting these variables explicitly to nil where we no longer need their value), but this is error prone, and a programmer should not have to manage that explicitly in the source code.
This automatic unsetting of unused variable could be made in the compiler itself (like what Java does for its class compiler: local varaibles are represented in an integer indexed array, and positions that are no longer needed can be reused for other local variables, as you can see if you look at the Java bytecode; this analysis also occurs in C/C++ compilers, still not in Lua).
And the Lua compiler could even eliminate "dead code" trying to assign a value to a variable that is never reused later.
Such optimizations may be disabled in a debugging/interactive session using reflection mechanisms (where the user of the debugger may locally insert code, or may want to see the content of a local variable still in lexical scope even if it's no longer used in the existing code being debugged.)