It is basically a way for advertisers to get adverts on many sites, and only pay these sites money when they make a sale for them, there aren't many forms of advertising you can do that with!
The affiliate site will be given special links which go through to the retailer advertising (their site) this means the visitor is tracked, and if they buy something (or whatever the goal is) the affiliate site can be given a percentage commission.