What is the purpose of setState in React?