The Dai Li were formed by Avatar Kyoshi. She struck a deal with the 42nd Earth King to train an elite group of Earthbenders to be the police of Ba Sing Se to maintain it's cultural heratige, after a pesent uprising.
The Dai Li have now been corrupted by Long Feng, head of the Dai Li, and are now used to maintain balance in the city. As described by Toph, the Dai Li just use the current Earth King as a puppet, and he has no knowledge of the current events in Ba Sing Se or the rest of the world.
Recently, Long Feng handed control of the Dai Li to Princess Azula, and they form a coup to gain control of Ba Sing Se. When Long Feng was released from prison and he tried to double cross Azula, the Dai Li didn't listen to either of them, as they didn't know who would be ruling Ba Sing Se. Long Feng bowed down to Azula, and Azula is now head of the Dai Li.
The Dai Li Agents are one of the smartest and one of the strongest earthbenders. The Dai Li Agents has rock made gloves for an advantage in combat. They use to belong to Long Feng but Azula ends up controling Ba Sing Sei and the agents