Because it is a shortened form of 'He lacks the imagination necessary to do so.' In this the 'imagination' referred to is specific as it is defined.
There is no rule that says uncountable nouns cannot be used with a definite article. Indeed where the noun refers to something specific it is usual to use one. e.g. 'Pass the salt please.'
It would, however, be wrong to try to use an indefinite article with an uncountable noun as the indefinite article contains the meaning 'one'.
Student or Learner