Yeerks don't just swim in pools. They have to screw two other people in order to survive as a species and they swim with close to a million other Yeerks at the same time. The reason they evolved this swarming behavior makes perfect sense if we go with the "Yeerks are easy prey" theory: they evolved it for the same reason swarming fish did. It's harder to catch an individual Yeerk in a crowd of them.
With this in mind, they would likely have evolved forms of cooperative prey evasion and reproduction when they developed intelligence. From there, it's only a few million years until they begin to need a form of government in order to dictate who reproduces, who protects the pool by infesting, and whatever else they need to accomplish. Intelligence for different reasons.