I do believe these concepts should not be applied as in boolean logic, with either
ALL PESSIMISTIC or
ALL OPTIMISTIC, but in a rather spectral fashion.
Happiness is closely linked to having lower expectations:
(...) Robb Rutledge says, “Happiness depends not on how well things are going but whether things are going better or worse than expected.”
Pessimism also leads to being more careful:
"Our findings revealed that being overly optimistic in predicting a better future was associated with a greater risk of disability and death within the following decade," said lead author Frieder R. Lang, PhD, of the University of Erlangen-Nuremberg in Germany. "Pessimism about the future may encourage people to live more carefully, taking health and safety precautions."
(...) "Unexpectedly, we also found that stable and good health and income were associated with expecting a greater decline compared with those in poor health or with low incomes," Lang said. "Moreover, we found that higher income was related to a greater risk of disability."
There are pros and cons in each of them:
Being optimistic allows people to pursue their goals in a positive way: to dream a bigger and better dream, which they can work their way towards. Optimists also seem to respond better to positive feedback, and part of being optimistic may be generating this feedback for themselves, i.e. thinking positive thoughts.
On the other hand being pessimistic may help people reduce their natural anxiety and to perform better. Also, pessimists seem to respond better to negative feedback. They like to hear what the problems were, so they can correct them. Again, part of why pessimists generate these sorts of negative thoughts is that it helps them perform better.
Keeping up a mood tending to pessimistic while giving your best in the tasks might be a recipe for greater happiness due to lower expectancies.