The barcodes on groceries are for the benefit of the store only, and are sometimes unique to that store, as the same item may be sold elsewhere with a different code.
The code will allow the store to maintain better stock control, and also ensures that when using a self scan checkout that the item is genuine, usually by weight. So you can't scan a the code from 50p can of beans, but put a gas powered BBQ in your basket.
For those with certain political ideals, the code can benefit them as the first digits are often the country code where the good were packaged (not produced) so you could avoid financially supporting certain factions.
Unique codes help with product recall, and sometimes fraud, so you can't claim against Tesco for a product bought in Sainsburys. It also aids security in that content tampering / contamination can be lowered, as the amended product had to be bought from that store first. If the code does not scan at the checkout because it is not in their database, the item will be rejected. Thus potentially saving the consumer from poisoning.
QR codes can now contain enough characters to write a small story, and link you to sites where more content exists. However, do avoid scanning codes where a payment is expected, such as parking meters, as criminals can easily overlay with their own, and then it becomes your loss twice over.