The Black Gate of Mordor was originally a gate built by Sauron, the Dark Lord of Mordor, to prevent invasion at the gap between the Ered Lithui and the Ephel Duath. It was probably built with the power of the One Ring, like the Barad-dúr. After Sauron's fall, it became a Númenorean garrison. Backed up on the other side by the Isenmouthe, and protected by the castle of Durthang to the west, it was redesigned to keep all of Mordor's evil inside, shielding the outside from it - and it from the outside. The reconstruction of Minas Ithil, Tower of the Rising Moon, as well as the construction of Cirith Ungol were also done for the same purpose.
However, during the aftermath of the Kin-strife in Gondor the watchfulness of the guards in these strongholds relaxed. Thus the Ringwraiths and Orcs re-entered Mordor, eventually overrunning the garrisons and inhabiting them for themselves. It was at this time that the tower of Minas Ithil was taken by the Nazgul, having its name changed to Minas Morgul, Tower of Sorcery.
During the War of the Ring, the Army of the West, numbering some 7,000 men, arrived at the Black Gate with the intention of drawing the Eye of Sauron away from Mount Doom, to allow Frodo the Ringbearer to cast the One Ring into the Crack of Doom within it. This they achieved, and the Ring was destroyed in the fires of Mount Doom, following which the Black Gate and the Towers of Teeth immediately collapsed.