A comment I often see on Goodreads reviews from low ratings is the reviewer complaining that the main character is "stupid." And they then go on to list the stupid things the character does. I've read some books lately which made me think, "Wow this character is stupid."
So how do we avoid our own protagonist from being stupid? I think that this clip from The Office explains it: