There are two main reasons for this.
One reason has to do with the rules of the American electoral system. In our system, we have a “winner-take-all” approach to elections for legislative seats. Whoever wins the most votes gets all of the representation in that district. A party can win 45 or even 49% of the vote in a certain district and not be represented at all. This is in contrast to some other countries’ systems of proportional representation where parties get represented in general proportion to how much of the vote they got. This makes it easy for many parties to exist whereas our system makes it much more likely that only two will exist.
A second reason has to do with the nature of our population and its history. We have always been a relatively centrist people. We did not have aristocrats trying to preserve conservative ways of life and many radicals supporting things like socialism. Instead, we have always had a massive middle class that tended to support moderate ideas. This has made it hard for many parties to arise on the fringes of political opinion.
So, we have a stable two party system largely because of the rules of our system and because of the essentially moderate nature of our populace.