What about Mathis, though? His 40.5% is higher than any of the challenging Democratic House candidate in Alabama that year.
Some conservatives who hated Roby didn't know about the write in campaign, and so voted D in disgust.
I find it really difficult to imagine Trumpists who are disgusted by a GOP candidate being "Never Trump" would vote for a Democrat out of pure spite, as opposed to just staying home.
I mean some might do that, but staying home seems like both an easier and more coherent thing to do for those who didn't know about the write-in campaign
Spite can be a pretty strong motivator. Some Trump voters might have been so angry with Roby that they wanted to turn her out of office, and voting for the Democrat would be the best way to accomplish that.
Also keep in mind that a typical GOP voter casting a ballot for a Democrat is worth twice as much as somebody staying home, leaving the contest blank or writing in somebody, so it wouldn't necessarily take all that many protest votes to dramatically improve the Democrat's share of the vote/margin of loss in a situation like this.
If just one in three of the protest voters did this, it'd have as much impact as the other two writing stuff in or leaving it blank.