Just look at Lore. He wiped out a colony, and could do far worse damage if he was both more competent and stable. It eventually escalated to the point where Data had to shut him down, due to the danger he posed to the rest of the Federation.
I don't see how star fleet allowed Data to remain onboard after that one. Being in the tech industry I often feel the Federation's infosec is lacking in often trivial ways (unless the episode calls for better security of course 🙂), but maybe they have just accepted that sort of thing as the cost of doing space business since it happens all the time. So Data's benefits out weigh his risk.
I thought picard was crazy for questioning data in his quarters alone in clues. Especially after they confirmed something was wrong with him by catching him in a lie.