Yes toothpaste does expire and eventually go bad so it's best to use the toothpaste up before the expiration date.
However even when the toothpaste has expired the toothpaste is still safe to use but the expired or old toothpaste may not be as effective at cleaning your teeth properly like fresh toothpaste would be.
Toothpaste lasts from 12 to 18 months past the toothpaste expiration date so it's best to use the toothpaste up before that time has passed.
But you can still safely use old expired toothpaste even well past those 18 months without getting sick.
Old toothpaste is not harmful to your health.
But it's best to use fresh toothpaste to get your teeth really clean.