"It is an expensive, but necessary investment."
Translation:Det är en dyr, men nödvändig investering.
The det is not referring to the noun in this sentence, it is just a formal subject or a dummy pronoun because the sentence needs some sort of subject, so you just put a det in there to act as the subject when you want to present something. So, it is not actually referring to investering.
You can think of ’it’ in ’it is raining’ in English which is a similar construction, where ’it’ doesn’t really refer to anything.