Patents were largely designed to enable the state to have a selectively published library of what was being invented in the country and to reduce the power of trade guilds, who had huge power at the time. Offering a limited monopoly backed by force of law was one of the few incentives that worked for acquiring access to the kind of trade secrets you needed to keep your edge on the battlefield.