Why is there a Shrine of Talos in Markarth?

As mentioned by @DCShannon in the comments, the Markarth Incident played a big part in the worship of Talos in Markarth, and Skyrim on the whole. 25 years prior to the events of the game Ulfric Stormcloak (re)took Markarth from the native Reachmen, who later became the Forsworn as a result of this event. The requirement stipulated by the While Gold Concordat of outlawing the worship of Talos was not actively enforced by the empire, hence why the shrine was still used at the time.

However the Thalmor used the carnage Ulfric caused - however nobly - to insist that the Empire strictly adhere to the Concordate. This played a notable part in the uprising of Ulfric's rebellion and the city of Markarth supported him - as such the pressure from the Empire to suppress Talos worship was less strongly felt in the city, however, the presence of Thalmor agents forced worshippers of Talos to do so in secret. You can even choose to aid the Thalmor if you feel so inclined!

For all intents and purposes as far as the Thalmor are concerned the shrine is closed and remains unused. This is why a certain someone decides to meet you here - no one will disturb you.

As for why the Thalmor didn't actively shut it down, dismantle, or otherwise destroy it isn't made clear - perhaps they thought the threat was enough to stop people, or perhaps they secretly wanted people to keep praying in private so that they could be routed out and imprisoned. Just to clarify, the shrine is basically entombed within a small mountain - you couldn't destroy the entire structure, but it would make sense to remove the statue itself.