What's the word for an unused, enclosed space between two apartment buildings?
It's also called air shaft.
Air shaft: (architecture) A vertical (or near vertical) opening (shaft) running from a courtyard to the sky, thus allowing air to circulate to high-rise apartments or offices.
[Wikitionary]
Or air well
Air well: a court enclosed within walls and open at the top for supplying air to windows — called also air shaft.
[Merriam Webster]
There's a whole article about air shafts in NYC on 6sqft, I'll just copy-paste the relevant quote:
When exterior windows finally became mandatory in the 1880s, developers were naturally eager to comply with the city’s new building law but without losing a significant amount of building space. For at least two decades, this led to the construction of buildings with interior air shafts so narrow tenants to shake hands with their neighbors’ in adjoining buildings.
[6sqft]
Another quote from BrianWestbye's blog:
So much goes on in a Harlem airshaft. You get the full essence of Harlem in an air shaft. You hear fights, you smell dinner, you hear people making love. You hear intimate gossip floating down. You hear the radio. An air shaft is one great big loudspeaker.
Thanks to Mari Lou A for the links!
Wikipedia article on the NYC law that created air shafts
What the OP describes is a lightwell. That is, however, a broader term, as it also covers (and is, perhaps, more often used for) a similar shaft within a building, i.e. for one that is enclosed on all four sides by the same building. There does not appear to be a term specifically for a lightwell of the kind that is described by the OP, i.e. one that is enclosed by parts of two separate buildings.
As the Decapitated Soul's answer on this page points out, such an architectural feature can also be called an air shaft. The choice between the two terms presumably depends on whether one regards illumination or ventilation as the principal benefit that it provides.
A defining characteristic of a lightwell is that it is too narrow for its bottom to be used or any significant purpose. That distinguishes a lightwell from a courtyard, which is large enough for its bottom surface to be used as a yard. The distinction between a lightwell and a courtyard is not precise, but it probably has more to do with the ratio between its width and the height of the building, than with the width itself.