The difference is technical: global variables are stored in a globally accessible table (it's called _G and you can access it manually), and local variables are stored in Lua VM registers. For that reason, globals are accessible everywhere, but locals only accessible within the scope they were defined (file, function, block of code, etc). For the same reason, locals are faster, and are limited to 200 at a time in any given scope.
Global to the lua state, anyway (with löve, it may matter, since you can have multiple synchronous threads that have their own lua states), but the globals are really just keys in a table that's, by default, as raidho already said.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
it will print 'nil' because the second file is accessing the global variable x, which does not exist, because x is local to main.lua, and there isn't a global with that name.