On the most basic level, the ants are symbolic of the forces of nature that man has to struggle against in order to create his own civilized world and to survive. Leiningen is an everyman, a representative of mankind, and of "man alone" in a hostile universe. He has no one but himself to rely on to defeat the ants, which become a titanic force ranged against him and, metaphorically, against humanity.
The secondary symbolism, which ironically constitutes a deeper "message" in the story, concerns man's arrogance. The ants are obviously capable of a gigantic level of destruction when they are massed in the billions as they are here, but the crucial point about them isn't so much their numbers, as the fact that the ants actually think the way humans do. They devise ways of counteracting Leiningen, as in the manner in which they cross the moat. They engage in self-sacrifice in individual numbers in order to accomplish the larger plan of overrunning and defeating Leiningen. Seldom does man condescend to attribute any kind of active intelligence to a species other than himself.
A final thought about the story is that it's a kind of strictly terrestrial version of H.G. Wells's The War of the Worlds. The vulnerability of any "best-laid plans" is revealed in both stories, which are warnings against complacency and the folly of man's viewing himself as embodying unchecked power and dominance. The ants are comparable to an alien force like the Martians in Wells's novel. In themselves the ants seem almost to have a supernatural quality, and are a kind of retributive force punishing man for his own unthinking encroachment upon nature.