For example, I contributed $20,000 total as my principal and I made a profit of $2,000.
Can I withdraw the $20,000 before age 59 without paying tax or penalties?
Yes, you can withdraw up to the amount of your contributions ($20,000 in this case) at any time without any tax or penalty.
Roth IRA distributions are ordered such that contributions come out first, so your first $20,000 withdrawn will consist entirely of contributions and no earnings. A distribution before age 59.5 or before you have had the Roth IRA for 5 years will be a non-qualified distribution, but even a non-qualified distribution of Roth IRA contributions does not have any tax or penalty.