This question seems to me to be such an obvious question, that it must be answered somewhere.
As I understand it is necessary to buy bitcoins using dollars or some other currency. Where do those dollars etc. go?
When you buy a bottle of soda at the convenience store, where does the money go?
The money goes to the party that sold it to you -- that party owned the bottle before you owned it. You might be able to trace ownership of that bottle all the way back through the supply chain, to the point at which it was manufactured. It probably had several prior owners before you got it.
Bitcoins are like a commodity that works the same way.
If you purchase from a market exchange (like Mt. Gox), here's how that works. Mt. Gox, like most market exchanges, operates using deposit accounts.
To buy $100 USD worth of bitcoins you must have deposited $100 to your account with the exchange. To sell 10 bitcoins you must have deposited 10 BTC to your account with the exchange.
So when you trade your $100 USD for someone else's 10 BTC, your $100 goes to their account, and their 10 BTC goes to yours (if there were fees, the amounts would be adjusted appropriately to cover fees).
Then when you withdraw your BTCs, the exchange will send that amount of bitcoins from the exchange's wallet to yours. When the seller withdraws the USDs (or whatever currency the coins were sold for), the exchange will send those funds. This generally occurs through the banking system, with the funds eventually arriving in the seller's bank account.
There are other types of bitcoin sellers -- direct sellers, who have an inventory of bitcoins that they purchased previously, or will make a trade behind the scenes to be able to deliver your order. So the dollars from your purchase goes to them in exchange for the bitcoins they owned.
Then there are other types of trades which involve risk. These include financial derivatives where you may speculate on bitcoins using cash but until you actually withdraw those bitcoins to your own wallet, you only own a claim against those bitcoins (or against a financial position on bitcoins). But that is an example where there is not a simple buying and selling of bitcions at a certain price.
Now every bitcoin in existence originated from mining. Mined coins arrive 50 at a time about once every ten minutes. They are earned by a mining operator (or mining pool and distributed to the mining operators who were mining). To mine, one must buy expensive hardware, expend the effort to build and operate the equipment, and purchase the electricity expended during mining. The mining operators can then deposit their bitcoin proceeds to an exchange to sell them and receive cash in exchange.
It's like when you buy anything else. When you trade your dollars for somebody else's eggs, you get the other person's eggs, and they get your dollars.
You can then sell the eggs to somebody else if you like - then you get their dollars, and they get your eggs. If you are able to sell your eggs for more than you paid for them, you make a profit.
Instead of buying eggs, it is possible to mine them (using a device commonly known as a 'hen'). Hens make eggs out of thin air, and are effectively a license to print money since the eggs they make can be traded for dollars. They do require fuel to run, which costs money. Miners need to determine whether their earnings from mining eggs is enough to offset the fuel costs.
Unlike eggs, however, there is a fixed limit of 21 million bitcoins that will ever be created, which makes them relatively scarce, and helps give them value.
Directly to people who are currently selling (if you don't count the minor exchange fees).