Spending time with loved ones could be one of the best ways to protect your brain from dementia, according to new research.