There were actually TWO coups of Ba Sing Se depicted during the series. The first was covert, while the second was more of a bloodless invasion.
The Dai Li Coup
Years before Aang & his friends visited the city of Ba Sing Se, the leader of the Dai Li - the city's police force - had begun working to erode the Earth King's power and enhance that of the Dai Li. By the time Aang had arrived, the Earth King was little more than a figurehead, and all of the REAL power in the city belonged to Long Feng, the head of the Dai Li. Feng had manipulated the city to such an extent that nearly all members of the Dai Li were loyal only to him, the Earth King had no idea what things were like outside of the palace, and the city populace itself was too scared of the Dai Li to do anything about the situation. The Council of Five eventually learned of the coup, but by then it was too late. In essence, Long Feng had become the Earth King in all ways but the title & throne itself.
In fact, Feng was so confident in his control of the city, he felt little need to address an invasion attempt by the Fire Nation. Unfortunately for him, he underestimated the resourcefulness of the Avatar and his friends, ultimately losing his position (AND his freedom) when his duplicity was exposed to the actual Earth King.
The Fire Nation Coup
Even after his arrest, Feng maintained the loyalty of the Dai Li. Although their power had been greatly diminished by the actions of the Avatar, the Dai Li still had a fair amount of control over the city as its police force. However, after striking a bargain with Princess Azula of the Fire Nation, Feng soon found himself losing the Dai Li's loyalty to Azula instead.
Once she secured the loyalty of the Dai Li, Azula quickly launched plans to take over the city from within. By the time her coup was finished, she basically had only to open the gates and let her father's army inside. Both the city's populace as well as its limited military put up some small measure of resistance, but any such threats were quickly eliminated by the combined forces of the Dai Li and the Fire Nation troops.
Summary:
As you can see, neither coup really offered the Earth King or his military the chance to resist. By the time they realized the first one was happening, it was done. During the second coup, they were simply out-matched and had little chance of success.