Nothing I say here is original; it is heavily influenced by Tabarrok's thinking on the matter. This post started as a Facebook comment in response to a friend's question; I am putting it here so I will be able to find it again and refer to it easily.
The question was "To what extent should governments try to enforce intellectual property rights? ... How would we determine, in principle, whether intellectual property laws are a good idea for governments to keep enforcing? (And, what's your best guess as to what we should be doing right now?)"
The default Economist answer to any question of the form 'To what extent should governments do X?' is always 'Until the marginal costs of doing more X start to exceed the marginal benefits.' I am only half joking when I say that the procedure for getting an Economics PhD is for people to drill the decision procedure 'Do things until marginal costs exceed marginal benefits, then stop.' into your head until it would be the first thing you mumble if you got dragged out of bed in the middle of the night and asked a question of this form.
The marginal cost of each additional year of intellectual property protection is the monopoly deadweight loss, plus the loss of knowledge diffusion and the innovations that would have been created based on the thing if it was a public good. This latter term is often dramatically underestimated. This marginal cost is probably roughly constant over time for most things, but will increase over time for important foundational innovations.
The marginal benefit is the incentive to innovate and create the thing that is generated by the difference between the monopoly profits under the government-IP system and the state of nature where people keep things hidden. Note that monopoly profits are not the same as the deadweight loss; they are just a transfer and therefore not a social cost. This marginal benefit decreases over time; older IP is almost always less valuable to a monopolist because substitutes will be developed.
Finding the exact point where marginal benefit equals marginal cost is always tricky in practice, but this gives us a few obvious guidelines:
Different types of IP should have different types of IP laws. IP law should be based on how expensive something is to create, how likely people are to create it anyway for non-profit motives, what the expected profit flow looks like, and how valuable it would be in the public domain.
Some things should not get any IP protection. Others should get a lot.
If 90% of the profits from a thing come in the opening weekend, and it takes more than a week to copy it, there is no need for IP. (If copying is instant, the proper length for IP protection is a few weeks.)
If we routinely see individuals producing a thing without any expectation of payment, and/or producing it is cheap and brings status rewards, there should be no IP protection. All it does is further reward people who won the attention/status lottery.
The 20-year patent for expensively researched industrial processes seems like a decent balance when the market for the product is small; larger markets and easier scale-up imply shorter optimal patent terms.
Further exploration can be left as an exercise for the reader.