Actually... in a few cases, the expiration date is quite valid and mandated by state law, such as with milk (at least for NY and NJ, that I'm familiar with). Or would you open a gallon of milk a few months past expiration date?
Otherwise the majority of expiration dates are not legally mandated and are there because the producer/manufacturer wants it there. And, let's be clear, it's not a scam to clear the shelves, because in most cases, the producer sees no income from unsold cans that are discarded because they're past the expiration date. The producer puts it there because they don't want stale food being sold that would ruin their reputation. Even if the food in question is free from any bacteria that would make it 'go bad', food has a limited shelf-life before the ingredients start separating and decomposing.
I don't know about Pepsi. But if a can of Diet Coke is a few months past expiration, it almost always tastes bad.