Dem Spiel hat es an Spannung gefehlt.

Dem Spiel fehlte es an Spannung, was es an Präzision wettmachte. What the game lacked in excitement it made up for in precision.
Just curious why “an” shows up with these words. Actually, why a preposition at all.

The formula for this construction is a dative object + impersonal “es” + “fehlen” + “an”.

But it’s not the only way to use “fehlen”:

Dem Spiel hat Spannung gefehlt. - The game lacked suspense.
This is a neutral expression that just states that there was not enough suspense. Maybe even none at all.

Dem Spiel hat es an Spannung gefehlt/gemangelt. - The game was lacking in the suspense department / when it comes to suspense.
There was suspense, but it left you wanting for more. It’s just not enough.

Dem Spiel hat die Spannung gefehlt. - The game was missing any suspense.
There was none at all, even though it should be an essential part of it, i.e. it was disappointingly boring. The definite article here points to the suspense that you would have expected but that is missing. It’s like an important ingredient is missing, “der letzte Schliff”, the condiment without which it all tastes bland.

I think the “an” can be thought of as “some amount of”, especially when combined with a qualifying noun, in which case it can be replaced with “von”:

Die Menge an/von Leuten die hier vorbeifahren ist unglaublich.
Er nahm eine Menge an/von Dingen mit.
In dem Geschäft gab es eine Auswahl an/von Bohrmaschinen.
Hier ist eine Liste an/von Dingen, die wir noch brauchen.
Fallen Roboter in die Kategorie an/von Dingen, die prinzipiell als Rechtsträger und Pflichtadressat in Frage kommen?
Zu verschenken: Potpourri an/von Dingen zum Basteln

When that noun is missing, maybe one can think of “an” as “when it comes to”:
Arm an Dingen, reich an Leben
Dem Spiel hat es an Spannung gefehlt.

So maybe it’s similar to the french “de” or the finnish partitive case?
But ultimately it seems to always be about a certain amount. Even fehlen/lacking is about an amount after all.