This joke relies on the fact that mathematical expressions, just as expressions in natural languages, may have multiple meanings. Like other puns, the humor is derived from an ambiguous meaning; in this case, the expression 10 in the binary numeral system is equal to the decimal number two.
Another pun using different radices, sometimes attributed to computer scientists, asks:
The humor lies in the similarity of the abbreviation for October/Octal and December/Decimal, and the coincidence that the two representations equal the same amount (31 Octal is 3*8 + 1 = 2*10 + 5 = 25 Decimal).