Because it has two holes in it for two legs, hence a pair.
According to The Mavens’ Word of the Day, pants in the plural form is an Americanism first recorded in 1840. The word is short for pantaloons, a term that originated with a character in Italian commedia dell’arte who wore both stockings and breeches. World Wide Words states that these types of clothing (pants, underwear, shorts, tights — or the equivalent terms for them) were made in two parts. One part for each leg, then belted in the middle, somewhat like chaps on cowboys. Over time, they ended up as one piece of clothing, but the habit of referring to the old “pair” persisted.