Your contributions to a Roth IRA are never deductible. Therefore, you may always withdraw them tax and penalty-free.
You may withdraw your Roth IRA earnings tax-free if you take a "qualified distribution." However, if you take a "nonqualified distribution" you may have to pay tax and a 10% penalty on your earnings.
The interesting thing about Roth IRAs is the "ordering" of the distribution. Your nondeductible contributions are distributed first, so you can always withdraw what you have contributed without having to pay additional tax or penalties.
What is a qualified distribution from a Roth IRA?
For a distribution from a Roth IRA to be "qualified," it must meet both of the following criteria:
It must not occur within five taxable years beginning with the first taxable year for which the owner contributed to a Roth IRA. In other words, if you opened your Roth IRA in 1998, you cannot make a qualified withdrawal before 2003.