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.
House races are a different landscape than presidential or senate campaigns, and far less partisan. As the house was viewed as Safe R in the lead up to the election, some people in this district clearly felt free to essentially say "since we have a big majority, we can be picky about who is in that majority". There's also an argument that Roby had the votes to win no matter what, but a closer margin of victory would teach her a lesson.