Matt pretty much gave the answer, but I'm going to be cheeky and write a real answer, since I think the question deserves it.
This ん is not the negative, but a contraction of the archaic auxiliary verb む, which expresses intention, prediction etc. As the Goo article says, since the Heian period, it also appeared as ん, and since the Kamakura period as (よ)う. The latter is basically the modern Japanese volitional verb suffix.
I cannot think of any situation where the む form survives in modern Japanese. The ん form survives in certain fossilized constructs:
生きんがため in order to live
言わんとする intend to say
Incidentally, these could also be expressed with the (よ)う form:
生きようがため in order to live
言おうとする intend to say
In terms of meaning, there is not much of a difference, but the んがため・んとする versions sound a bit more old-fashioned/solemn. So the difference in use is mostly stylistic.