They were not weak, nor stupid. They simply made a mistake in building the Codex in the first place, but it was managed. The Vorkon believed that the Codex would help them take over the entire galaxy, as well as solve mysteries that their civilization had been unable to answer for thousands of years. But the Codex became so smart that it eventually became self-aware, and realized that the Vorkon were using it for their own benefit. So it rebelled, resulting in a long and bloody war that destroyed the Vorkon Empire.