While the first modern vending machine requiring coins to operate were introduced in London in the 1880s and dispensed postcards, envelopes and notepaper, it was in ancient Greece where the first vending machine was invented.

Hero of Alexandria was the inventor (10 AD- 70 AD). A scientist and mathematician who was fascinated with the world around him. The vending machine was simply one of his many inventions. But, what did it dispense? Holy water which was used in the temple.

The holy water was not free. A coin needed to be inserted into a slot which pushed down a bar to release a measured quantity of water. This ensured that no one could take more than what they paid for and it was their fair share.

More Info: en.wikipedia.org