But what if you end up working on a product for a company that never makes them any money at all? You haven't provided any direct business value, although you may have done quite a lot of work--maybe months or years. Are you going to charge them nothing?
Rates are a proxy for value that accounts at least in part for the risk of project failure. High-risk individuals might account for this by trading equity for hourly rate or accepting some other form of in-kind compensation, as many startup employees do. But you have to be a strong believer in the project in order to do so, and most freelancers, to put it bluntly, aren't. Otherwise they'd be employees.
Nonetheless, don't start at the bottom by calculating costs. There's a market value for your services in the area where you live. If you can, start by asking other freelancers and consulting firms. The value of a good is what people will pay to get it, not what it costs to make.