Changes to a person's cholesterol over time might have a surprising impact on their risk of dementia, a new study found.