"I wish I were an optimist."
Here's why:
* "Were" is used in subjunctive mood when expressing a wish or hypothetical situation that is contrary to fact.
* "Was" is the past tense of "be" and wouldn't be grammatically correct in this context.
The sentence expresses a desire for something that is not currently true (the speaker is not an optimist). The subjunctive mood is used to reflect this hypothetical situation.