I'm creating an erc20 contract and deploying with metamask. I only have 3 dollars in ether, so I could only afford 5 gwei for gas. It's been 3 hours, how long will it take? It looks like 40 gwei would cost something like 30 dollars, and I don't want to spend that much. Thanks!
It's impossible to say.
If you look at the chart at https://etherscan.io/chart/gasprice you can see that basically every day there are transactions mined which have a very low gas price (even much lower that yours). But it's impossible to know whether such transactions have been paid in some other means - for example someone offers some monetary payment to some high-end miner to include his small-gased transaction.
But the average gas prices have been higher than 5gwei for a long time now. So it might take an hour for your transaction to go through - or maybe a year.