Smith is, for lack of a better term, an intentional bug.
The Matrix has two basic tenets
- It must accept the input of the users
- Every action has an equal and opposite reaction
In other words, The Matrix is designed to produce the expected outcome of its users. The reason people don't go flying around or bashing walls, is that they literally don't expect them to work that way. Or, to quote the Hindu-ish kid
There is no spoon
The Matrix can't actually enforce gravity. Or stop you from punching through a wall with your bare hand. That's why people like Morpheus can make long jumps and Neo can fly. Literally, if you expect it to happen, it can happen (likely only applies to places where your expectations can shape the outcome, or Neo wouldn't have needed the Keymaster).
The problem for The Matrix is that, the larger the deviation from reality, the larger the breakdown that occurs as it tries to balance things. Part of the deal The One must make to save Zion is that they break down whatever The One is making go haywire and neutralize it, and then reboot The Matrix. Because of the size and scope of The Matrix, there's no way to figure out what the next One will break, or how The Matrix will respond.
The One is, essentially, both the cause and solution of the bug. Zion is, simply put, a way to keep motivating The One to fix the bug and keep The Matrix working.
The catch is, with the second movie, Smith begins to behave like a virus. But a better explanation is that Smith is not a virus per se (where his goal is to keep replicating) but the bug corrupting everything around it. A better term might be something like a buffer overflow, where a bug in a program allows it to exceed its limitations and corrupt other programs around it.
ORACLE: Everything that has a beginning has an end. I see the end coming. I see the darkness spreading. I see death. And you are all that stands in his way.
ORACLE: Very soon he's going to have the power to destroy this world, but I believe he won't stop there; he can't. He won't stop until there's nothing left at all.
NEO: What is he?
ORACLE: He is you. Your opposite, your negative, the result of the equation trying to balance itself out.