There was this interchange with Korob in the episode "Catspaw:"
MCCOY: These look real [regarding the plate full of gemstones].
KOROB: They are, I assure you. Diamonds, rubies, emeralds, sapphires. All the crystalline forms that you cherish above all things. A fortune of them for each of you--if you leave here without further inquiry.
KIRK: We could manufacture a ton of these on our ship. They mean nothing to us.
So, while they are capable of manufacturing diamonds, rubies, emeralds, sapphires--all the crystalline forms that are cherished above all things, evidently (and perplexingly) dilithium is something that can't be manufactured shipboard.
Even if dilithium crystals COULD be replicated aboard Kirks Enterprise, there is no evidence that they could be created in the time available (with a Klingon warship swooping in).
Say the crew did have the capability of creating crystals......but that it would take several days or weeks to do so. This would still make having naturally occurring crystals vitally important (and why dilithium mines are still important even in the 24th century).
A modern day example. Uranium waste from nuclear reactors can be reprocessed to create new nuclear fuel for other reactors. But uranium mined from the ground right now is cheaper so reprocessing is not used that much.