Various things. Pessimissim and optimism are complex ideas, and there’s no one process that causes them. Sometimes people have had bad things happen to them in their life, and they think life will continue to give them bad things, which makes them pessimistic. Sometimes religion helps people be more optimistic, because they believe that God or gods are watching them and looking after them. Sometimes people think that society is changing (which it is), and if they like the change they’re optimistic, and if they don’t they’re pessimistic. And sometimes people read newspapers that tell them about crimes and wars, which makes them feel like the future is getting more dangerous, even if the number of wars and crimes is going down. So it’s more the way that people personally see the world than a scientific thing that happens to the brain. That said, depression can make people pessimistic, and depression can be treated medically with medicines sometimes, but the causes of depression are still being explored by doctors and psychologists.
This is a very good question, but incredibly complicated. I think some of it is hard wired into the brain, some people are just less optimistic than others. Another part is due to experiences, so if you’ve had good luck you might be a bit more hopeful about the future. But then there are people who have awful luck and still have high hopes for the future.
It’s part of a huge debate in science about nature vs. nurture i.e. how much are we born with and how much do we learn as we grow up.
Comments