The purpose was to both incentivize invention, but also require detailed specs of that invention to be given to the public. In exchange the inventor gets exclusive rights for a limited time.
If trade secrets cause knowledge to be held from the public and then ultimately lost that would be worse.
Whether that’s still relevant today I don’t know. In cases with massive research R&D like drug discovery they still seem really important.
In that case a trade secret wouldn’t be enough to justify up front investment if the drug can be copied and sold as a generic for cheap along side it.