Over the counter (OTC) pharmaceuticals general have a 2 year expiration date because that is how long the FDA makes manufacturers test and validate for. Some products will be good for a period after this, perhaps a long period, but because nobody was required to validate, they don't put it on the label. I know the fluoride in toothpaste is very difficult to keep stable, so it probably isn't as effective after its use by date. Sure, the suspension media and polishing powders will still get your teeth clean, but cavity protection from the sugar alcohols (sorbitol and glycerin) will go away.
I can personally attest that sun screen has a shelf life. I used some old stuff a couple of years ago when I went to the drags and the oils made my sunburn worse w/o the benefit of the spent blockers. Took me a couple of days in the sun frying to figure that one out.