To be fair, a lot of people do publish their working code with the paper. It helps people like me understand how to do the work.
Bad code is fine, good code is better, great code is great. Stick to fine and I can do my job and you can write papers knowing that your work will be used by many.
If it's that garbage, how do you know your results are correct? It should be at least non-garbage enough that someone else could theoretically check it, or you're not doing science at all.
You don't. But there are 5x-100x more bugs lurking in the methodology so triage is the name of the game.
A much bigger problem is that grantsmanship strongly incentivizes against verifying your methodology and being diligent in your construction of null hypotheses.
Filing taxes is not about handwriting either - I guess you missed the analogy. Research isn't about writing good code, but publishing your code is useful(for reproducibility, which is part of research), and if you're embarrassed by your code quality, then you should put some effort into it.
See, that's exactly what you shouldn't do if you want to encourage academics to release the source code.
Academic code sometimes only has been made to work on one machine (the author's). Someone reproducing the results should still have access to the source, even if they have to hack it to work on their system.