The Klan didn't get away with horrific acts of violence because they were legally allowed to wear masks—they got away with it because it was socially acceptable to terrorize, beat up, lynch, and kill people who were not WASPs. The police and other civic leaders were often members, and even when they weren't, they had tacit and sometimes direct alliances with Klan members. This led to law enforcement looking the other way when violent acts occurred, and they simply did not enforce plenty of existing laws that made the Klan's violent behaviors already illegal. Plenty of violence occurred without masks on. And even when the masks were on, law enforcement had more than enough cause to arrest people and unmask them.
Arresting, prosecuting, and convicting individuals who engaged in already-illegal acts of racially motivated violence is what stopped Klan violence. Beyond that, brave infiltration efforts to expose their inner workings and publicizing membership lists contributed further. An endless stream of newspaper articles documenting and decrying Klan activity as un-American helped, too.
Yes, the anonymity provided by the hoods emboldened horrible people to threaten and intimidate others, as well as commit horrific acts of violence. But the violence happened because it was allowed. Suggesting anti-mask laws stopped the Klan only whitewashes the past—and absolves political leaders, law enforcement, and American society itself, of their central role in allowing that violence to happen for decades. Klan violence didn't stop because masks became illegal—it stopped when people refused to continue looking the other way. And it took way too long for that to happen.
I don't have solid sources on this, but I'm pretty sure the masks were most useful for Plausible Deniability. Local officials didn't really want to fight the Klan, true. They still had to answer to State and Federal officials and out-of-state newspapers though. Klan members wearing masks allow them to claim to anybody asking tough questions that they can't do anything more against those people because they don't know who they are. (And allow them to deny some of them are infact members)
It's often tough to discuss logistics issues like this on boards. Everybody wants to find One Big Reason for something, and declare every other reason irrelevant. In reality, most large efforts to solve large issues require lots of different tactics. Often, no one tactic is "key" or "essential", but they all help out a little to achieve a goal. Taking away any one won't doom you or anything, but it will make things take a little longer and go a little harder.
— I wasn’t searching for one big reason, and I wasn’t declaring all other reasons irrelevant. I provided several reasons that are exceedingly well documented in Klan-focused histories for the decline of Klan violence (seriously, go read some histories and see how prominently mask laws play in the events).
— Alabama passed the first anti-mask law in the South in 1949—roughly 20 years after the national (2nd) Klan and its violent activities had been exposed and its membership severely dwindled (turning the Klan into a splintered group of uncoordinated and smaller local and state groups).
— The post-WW2 (3rd) Klan had alliances all the way up the local, county, and state-level political and legal ladder. They had direct alliances with governors. Local officials weren’t having to deny anything, because there was rarely anyone to answer to higher up the chain. In the states this occurred, hooded Klansmen weren’t really a thing like the 2nd Klan, and the violence continued without masks. The feds didn’t get involved until way late—FBI and the like cared about chasing communists more than they did Klan violence when it mattered.
— The 3rd Klan became a notable and present force of violence and intimidation throughout the South after the Alabama anti-mask law (and the other state laws that followed)
— The Klan robes and hoods most people envision were a staple of the 2nd Klan, and basically copied the costumes in Birth of a Nation—that is, 20+ years before mask laws (when they might have been helpful; at that time Klan membership numbered 3M-6M).
— The first and second Klan were organized and national. The third Klan was local and state specific, and never reached the membership levels of the former—yet mask laws didn’t stop Klan violence during this period.
— Alabama is a funny example—it passed the first Southern mask law thanks to a Klan-hating governor, and it later had a Klan-allied governor.
By the way, this period and the issues society struggled with was pretty much the focus of my graduate school work, and years of study since.
I believe it’s more than fair to interpret the mask laws as being fueled by recognition (by some) that times were changing, and a desire to avoid returning to the hooded times of the 2nd Klan. They were likely interested in preventing hooded Klan marches and intimidation acts—for example, Georgia’s 1951 mask law came a couple years after a group of hooded Klansmen stood outside a polling place to deter black citizens from voting, iirc.
I also think it’s wise to keep that interpretation balanced by recognizing that while perhaps not quite virtue-signaling, the mask laws—when viewed alongside the horrible racist violence allowed in the states that had mask laws—were passed by some people who wanted to unmask the Klan, and others who realized it was politically expedient to be seen doing so. In some cases—notably those states who allowed post-1954 Civil Rights-era violence and allied with local Klans—it provided an appearance of doing something, while then turning a blind eye toward the mask-free violence occurring in their states, and forging alliances with local Klan members.
Ultimately, to understand the period, its actors, and their motivations, we’re left digging through whatever records exist of public arguments made at the time for the mask laws, and looking carefully at who made the arguments, and how those arguments square with their actions in their states. Sadly, I’m not sure if there are many publicly available records online of that sort for someone to dig through.