duplicate content & ranking

According to Cutts, duplicate content can cause a website to not rank well in search engine results. But why is that?

JavaScript Alert: Duplicate content can lead to a penalty from search engines, causing your website to drop in rankings or even be completely removed from search results.

So, how can you avoid duplicate content and ensure your website ranks well?

Note: This code uses JavaScript to toggle the display of the alert message. If you want to disable JavaScript, you can remove the script tag or modify the code to use a different method.