Easy answer: Inflation happens because the dollar (as well as many other currencies) aren't literally worth anything but the paper they are printed on. In the old days, the paper money wasn't actually the currency, but a receipt to a valuable metal or object.
Same as it was back then, it is impractical to carry around several hundred pounds of valuable metal. So you carry around the receipts to several hundred pounds of valuable metal. Should the owner so choose, at any time he could take the receipts in and get the equivalent amount of metal back.
These first receipt issuers were soon to be bankers. The bankers started loaning out money. However, they realized that they could loan out more "Money" then the worth of gold that they had in their stockpile.
Problems came, but it wasn't ever really fixed.
Fast forward several thousand years, and you have the modern governments. THEY decide it's impractical to keep millions of pounds of valuable metal (gold, silver) in worth to back up the money, so they decide to get rid of it and switch to a FIAT system. This system is where the value of the money is determined by supply and demand.
Should the demand go up, the price goes up or visa-versa as seen in currency exchanges. Should the supply go up, the price goes down, as seen in inflation.
Oh, and in case you're wondering, to you, the common man, inflation really isn't a bad thing unless you keep your cash under your mattress, where it can't grow, but just devalue.