How many years is between 1871 and 2010?

There are 2010-1871, or 139 years between 1871 and 2010.

That is measuring differentially. If you mean to treat the years as a set, [1871-2010], and you mean "not the end points" when you say "between", then the number of years in the set [1872-2009] or (1871-2010) is 138.