When you buy a futures contract, your broker won't require you to stake the entire value of the contract. Instead, you'll only have to hold a small percentage of the cash needed for the purchase, which is called an initial margin payment.
The price of the contract will fluctuate. If you, as the contract holder, are showing too big of a loss, your broker may require you to deposit more money.
Most commodity traders will close a position before expiration. Most people don't have the space to store thousands of barrels of oil or (literally) tons of corn.
When you sell a futures contract, you should receive enough funds to cover the margin loan, and, hopefully, have some left over as profit.
For example, if you bought an oil futures contract for $70, and the price goes up to $75, you'll make $5,000 ($5 x 1,000 barrels) when you sell. In the interim, you may only have to hold a few thousand dollars in your brokerage account, so the return on investment can be substantial.