What factors may lead to someone contracting neurosyphilis?

Untreated syphilis. Untreated syphilis progresses, in most cases, to invasion of the brain and nervous system. This causes encephalitis and eventually dementia and death.
Having syphilis. One has to have had syphilis (an initial genital infection), not (or inadequately) treated it such that a chronic infection (when signs of secondary syphilis commonly develop), and then usually much later develop neurosyphillis. Age, hiv, certain meds, and other factors that would hinder the function of the immune system would all be potential factors that would contribute to developing it.