Carcassonne was first walled by the Romans in the 3rd century, expanded by the Visigoths, then turned into the French crown's southern fortress after the Albigensian Crusade took it from the Trencavels in 1209. By the 17th century it had lost its strategic value and was falling to ruin.
In the 1850s the architect Eugène Viollet-le-Duc rebuilt the conical roofs, the crenellations, and the outer walls — so the cité you see today is partly 13th-century and partly the most famous 19th-century medieval restoration in Europe. It's the reason the place looks the way fairytales think castles look.
The cité itself — the cobbled lanes, the Basilique St-Nazaire, the shops and restaurants inside — is free to wander. What you pay for is the Château Comtal and the ramparts walk above, run by the French national monuments service (CMN). The view from the tower battlements across the lower town and the vineyard plain is the reason people come.