Your reasons may vary but if you are a software developer you are probably reading code. And you have probably noticed some piece of code that does not make much sense, and would have been done better.
First assumption is code is badly written because it was written by a bad developer. Actually, a good part of bad written code is developed by developers who are capable of producing good quality code. So why do good software developers create bad code every now and then.
There is usually a story behind the bad code done by a good developer. The stories vary, a story can be the usual fast coming deadline or it can get very interesting. I have seen code that overrides functions so that it can provide extended documentation, or UI components hardwired to show limited elements after a user experience study although it still allowed to add more elements.
Does having a story give you a right to produce bad code? A story may make you feel better about it but it does not give you the right. What separates a regular software developer from a damn good software developer is intolerance to bad code. No matter what the story is, and who originally created the code, good software developers refactor the code to good code quality. And this is why some of the most successful refactorings have a good beer story attached.