The object id is the actual identifier of the real 'object', the entity id is allocated to 'dynamic' entities on the fly and is how GG connects Lua scripts to real objects internally.
An object may not have an entity id btw.
Some Lua commands use entity ids but some need object ids. For example the ray casting commands return the object id because they may detect an object that doesn't have an entity id (i.e. a static entity).
Been there, done that, got all the T-Shirts!