Imagine writing code so useful and flexible it lasts for decades, being used every single day by billions. DNS might not be perfect but it's one of those simple and elegant systems that keeps on trucking because of its simplicity.
The point is that the moment it was written is even more important than how well it was written.
Though I suppose that if it had been really bad code it would have been replaced long ago.