Yes, you can withdraw the contributions to a Roth without taxes or penalties (but not the earnings). There may be a little additional tax reporting--I think you'll receive a 1099-R for the distribution, but the code will indicate no tax is due. I'm sure someone will chime in if I'm wrong.
However, if it's likely you'll need the money later in the year, there's little point in doing so. You'll earn next to nothing on a safe investment, and you may lose money in a risky investment, so unless you want to roll the dice, don't bother. However, if there's a good chance you won't need the money, then sure, why not.