In short: the unfolded state is a high-energy state of the protein, which will move towards lower-energy states. Some of these states are the folded protein, while others states are denatured protein (forming "wrong" interactions with itself or other proteins). Energy barriers between these states keep the protein in the denatured state even though the folded state might me more favorable.
Or in other words: it's trapped in the denatured state because of kinetics, even though thermodynamics would favor the folded state.
A nice figure to illustrate this: http://www.ghrnet.org/index.php/jbmbr/article/viewFile/1027/1397/6798
If you go into a little bit more detail, you will find that a lot of proteins (especially larger ones) are usually folded by chaperones. These helper proteins will bind to the emerging protein chain to prevent it from aggregating. In a sense they guide the protein to a folded state. In a similar way, chaperones can help proteins overcome the energy bariers that normally prevent it from going from an aggregated state to a folded state.
This review in Science is very complete, but also contains some nice figures that give you an idea of what happens: http://science.sciencemag.org/content/353/6294/aac4354.long /
If you're a pirate: http://science.sciencemag.org.sci-hub.bz/content/353/6294/aac4354.long