Expiration dates on meds or med-like compounds represent the longest time for which the compounds have been tested for efficacy and safety.
Generally speaking, every formulation change (shape, size, format, bottling) of such compounds requires new testing.
It is cost-prohibitive and unpractical to test every reformulation for 10 years, so they test for a couple of years only since most people will use up these compounds within that time frame. Also it stops people from self-medicating (in many instances for prescription medication)
If I remember correctly, either the Departement of Defence or the US army tested a large number of medication for % of active compounds to see if medication did really expire (considering a $1 billion cost of medication turn-over every three years for expired medication). Basically all the medication tested had more than 90-95% of remaining active ingredient 10 post expiration date. (The experiment was started in the 1980s).
I have caffeine tabs expiring in 2001 and they still have the same kick.
Its a legal thing above all else. And secondly, its an economic thing.
Hope this helps,