"Fence laws originated with disputes over livestock, which may wander off their owner's land and cause damage. Judges and legislators have developed three different schemes for allocating the costs of restraining animals. Countries or states with "fence-in" systems require ranchers to build and pay for fences to keep their cattle on their land. "Fence-out" regimes allow livestock to go where they please, and impose the cost of fencing on neighbors who don't want animals on their property. Lastly, a few Solomonic legislatures have split the difference, forcing neighbors to share the cost of a fence, even if one of them doesn't want it."
See the whole essay at Slate.