The City Watch is a law-enforcement institution charged with policing King's Landing. They are informally known as "Gold Cloaks" due to the gold-colored cloaks their members wear as part of their uniform.
The City Watch of King's Landing is a strong, formally-trained and well-equipped force of guardsmen under the direct authority of the King on the Iron Throne. Their salary is paid by the kingdom as a whole and unlike many of the kingdom's other institutions they do not swear fealty to any lord other than the king.
The City Watch is supposed to double as a defense force in the event that the city is attacked, though, prior to the War of the Five Kings, a major attack on King's Landing had not occurred in generations (the Sack of King's Landing by House Lannister during Robert's Rebellion occurred after their army had already been let inside the gates, and was more of a massacre than a battle). The City Watch is not manned by true soldiers, as was shown during the Battle of the Blackwater when many panicked and fled when the tide of the battle turned dire.
The City Watch promotes by merit, one of the few institutions in Westeros not to recognize the status of birth. Its previous leader was Commander Janos Slynt, a butcher's son who rose through the ranks. Slynt was dismissed by Tyrion Lannister and replaced as Commander of the City Watch by Bronn, a lowborn sellsword in Tyrion's service. After Tywin Lannister assumes his duties as Hand of the King, he dismisses Bronn from command of the Watch.
The leader of the City Watch is referred to as "Lord Commander" when of noble birth but simply as "Commander" when not. Janos Slynt was a "Commander" due to his lack of noble birth. Following Lord Stark's arrest, Janos was named the new Lord of Harrenhal and elevated to the nobility by King Joffrey as a reward for his loyalty. After this point he was referred to as "Lord Commander". Bronn was referred to simply as "Commander", as he was not of noble birth. Nonetheless, there is no functional difference, other than manner of address, if the leader is noble-born or not.
All members of the City Watch are equipped with the same uniform, including an outer "gold" (likely bronze) chainmail tunic with some minor plate and scale armor in the front. They also wear similarly colored metal wrist, hand, and shin guards. The City Watch helmet is patterned, covers the top of the head, has a forward brim, and has jointed cheek-pieces. Attached to the helmet is an aventail, as well as a detachable mail veil that covers most of the face when latched to the brim of the helmet. The watchmen are commonly seen with longswords or spears, though they generally do not utilize shields.
Hand of the King Eddard Stark, in his attempt to remove Joffrey Baratheon and his mother Cersei Lannister from power after Robert Baratheon's death, tries to secure the loyalty of Janos Slynt and the City Watch through Master of Coin Petyr Baelish. Ned Stark reluctantly agrees with Littlefinger that they will need to bribe Slynt to make sure Slynt and the rest of the City Watch will support their side. Unfortunately for Ned Stark, Janos Slynt has already been bought by the Lannisters. When Stark and his guards attempt to seize custody of
Joffrey in the throne room, the City Watch under Slynt betrays them and proceeds to slaughter all of the Stark guards in the throne room and take Eddard Stark prisoner.
King Joffrey orders Janos Slynt and the City Watch to massacre all of Robert Baratheon's bastard children, even babies. Tyrion Lannister, while acting Hand of the King, is disgusted with Janos Slynt for carrying out baby-killing. Tyrion is also concerned that Janos betrayed the previous Hand, Eddard Stark, which led to his execution. Tyrion, who rightfully cannot trust Janos, has him stripped of his position and exiled to the Wall to join the Night's Watch. He replaces Slynt as Commander of the City Watch with Bronn.
Varys later remarks to Tyrion that Bronn is performing effectively as Commander of the City Watch. Bronn was able to restore order following the Riot of King's Landing and even managed to make a significant drop in theft during the lead-up to the Battle of the Blackwater. Bronn explained that he simply had the City Watch arrest all of the known thieves and killed them, fearing the chaos they would cause if they faced a prolonged siege. Varys reluctantly agrees that desperate times called for drastic measures.
A pair of Gold Cloaks accompany Ser Jaime Lannister to the dungeons to escort Tyrion Lannister to the throne room to be judged for the murder of King Joffrey I. Per Lord Tywin Lannister's orders, the Gold Cloaks put Tyrion in shackles.
When members of the Faith Militant go around King's Landing to rid it of what they deem sinful in the eyes of the Faith of the Seven, they stumble upon a shop selling idols of other religions. The Faith Militant proceeds to smash these "false idols" and terrorize the shopkeeper. When he pleads for help at two nearby Gold Cloaks, they simply turn around and do not intervene.
In the books
In the A Song of Ice and Fire novels, the Gold Cloaks are a force of some two thousand men, relatively well-equipped, who police King's Landing. While they promote by merit, they are not incorruptible and some Watchmen have a reputation for taking bribes to look the other way, though Ser Jacelyn Bywater is noted as one of the more honorable members of the City Watch. They are expected to help defend the city if it were to ever come under attack.
The King's Landing City Watch actually isn't the only one in Westeros. Out of the five full cities in Westeros, Oldtown and Lannisport, the second and third largest cities respectively, also each have their own City Watch. Lannisport's City Watch is better paid and thus can afford to train its members to higher standards than King's Landing's City Watch. It is unknown if the smallest two of the five cities, Gulltown and White Harbor, also have comparable police forces (or even some of the largest towns). The other City Watches have only been briefly mentioned, and given how much of the narrative takes place in the capital city, the King's Landing City Watch is almost exclusively "the City Watch" that characters refer to in the story.
While the City Watch existed since the early years of King's Landing, for many decades it was poorly organized, poorly armed, and irregularly outfitted in odds and rags. The true founder of the modern City Watch was Daemon Targaryen, younger brother of King Viserys I. After King Jaehaerys I died in 101 AL, Viserys ascended the throne, while Daemon set about to reorganize the City Watch into a more professional and well-trained organization. Daemon outfitted each member of the City Watch with a dirk, short sword, and cudgel, and armored them in black ringmail (with breastplates for the officers). Daemon also outfitted each of them with long golden cloaks, which they could wear with pride to impress petty criminals, and ever since they were popularly known as the "Gold Cloaks". Daemon eagerly led the reorganized City Watch in cleaning up crime in the alleys of the capital city. Nearly three decades later, during the civil war known as the Dance of the Dragons, Daemon fought for his wife Rhaenyra Targaryen's "Black" faction, against the "Green" faction which supported her half-brother Aegon II, and which controlled King's Landing. When Aegon II's younger brother Aemond foolishly led most of the Green forces defending the city away north to strike at Harrenhal, Rhaenyra's Blacks launched an invasion of the city using a combination of her dragons and the Velaryon fleet. So great was the Gold Cloaks' loyalty to Daemon that there was no siege: they mutinied en masse and threw open the gates of the city to the Blacks. When accused of being turncoats, their leaders responded that Daemon had given them their cloaks, and they were gold whichever way you turned them.
Bronn is not actually named as the new Commander of the City Watch in the books, though Tyrion does name him his Captain of the Guards and works closely with the City Watch. Instead, Tyrion replaces Slynt with Ser Jacelyn Bywater, a poor knight from a lesser branch of House Bywater who commands the Mud Gate. He is hated by Slynt because he is an honest man who performs his duties well and refuses to take bribes. He dies in the Battle of the Blackwater when his own Gold Cloaks retreat in a panic after they see Joffrey flee the walls and he tries to rally them back into battle. Jacelyn Bywater's role was functionally condensed with Bronn in the TV series (though Bronn doesn't die in the Battle of the Blackwater). The TV series's version doesn't state why Tywin dismissed Bronn, though it was probably for his low birth (which is one of the reasons he wanted Janos Slynt removed in the books). In either version, Bronn still increased his social position because of his exploits during the battle and was rewarded with a knighthood.
Note that "Gold Cloaks" is consistently written as two separate words, in both the books and the TV series's published materials (including the subtitles as well as the HBO Viewer's Guide and In-Episode Guides).