The #1 thing either you have it or you don't have it, and that's brains.
The #2 thing also either you have it or you don't have it, and that's passion.
The rest are in no particular order:
- Work together with experienced people
- Find books widely acknowledged as good and read them
- Experiment with programming on your spare time (comes with passion)
- Do not let girls, drugs, alcohol, and generally 'being cool' distract you.
(Well, I take back the thing about the girls.)
EDIT I just thought of one more thing to write, which addresses the issue of writing clean code in a more direct way than my other recommendations; who knows, it might appease our anonymous downvoter, in case their downvote was for being off-topic.
Try to write software systems whose complexity lies not within the code, but within the design. What do I mean by this: any program represents a solution to a problem. The complexity of the solution usually (granted, not always, but usually) depends on the complexity of the problem. An overly complicated solution would constitute overengineering, but an overly simple solution would be inadequate. (As Einstein said, things should be as simple as possible; but not simpler.)
Now, there are two ways of putting all the necessary complexity into a program: you can either have a monolithic (very simple) design which "just does it" with lots of complex code and tricks and hacks, or you can have an elaborate (complex) design which closely models the problem and consists of lots of bits of very simple, very straightforward, I could even say boring, code. Always prefer the second. That's what we call clean. (This was just an elaboration on @BryanOakley's statement about clever != good.)