Team rocket is just plain stupid. 'Nuff said
commented 49 minutes ago by ☠ĐarkĦeart☠
Pretty much all there is to it to be realistic.
Also, Team Rocket was originally there (in my opinion) to give comedic relief to the audience. If you want to talk of the episodes in real sense, they were frightened by the Espurr. And because of that they valued their own lives a lot more than any Pikachu.
They sometimes work alongside the main characters plainly because they know (or think) that they cannot get out of the fix they are in on their own, and combine forces to have better chances. It's not all that complicated. Anyways Team Rocket does actually work some good deed (you see new mechas every other episode which they make from scrap surprisingly), but it's just the conceit that pushes them back.
Hope I helped!