There are at least two main factors that contribute to our having a system in which there are two parties.
The first of these factors is legal one. It has to do with the fact that we do not have proportional representation. In our system, whoever gets the most votes in a district wins that district. A party can get 20, 30, or even 40 percent of the vote and still get absolutely no representation in that district. This is in contrast to proportional representation system in which a party getting 20 percent of the vote would get 20 percent of the representation.
The second of the factors has to do with the politics of the American populace. Americans are generally fairly centrist. There are not a lot of Americans on the far left or far right. We also do not have things like parties connected to a single ethnic group or religion. For these reasons, the two parties have to fight for the voters in the middle of the political spectrum. This means that there is not much room for a third party to arise as there would be if we had more people on the ends of our political spectrum.