What factors contribute to the maintenance of the two party system?
I certainly think that one reason why the two party system has taken a hold in America is because both parties represent a historical narrative intrinsic to the nation. America has been a nation that has found a comfort with the two party system. Over the last century, there has been little fundamental difference between the Democrats and Republicans. Both espouse liberal democracy and capitalist ideology. For the most part, the mainstream elements of both parties have contributed to a sustenance of the American Status Quo, without a real option for radicalized change. Putting aside potential differences in social or cultural policy, which might be diminishing itself, there is little political difference in both parties. If one is voting "Democratic" or "Republican," the vote being cast, for the most part, is in favor of liberalized government with capitalism as the means by which economic policy is being followed. It is in this where there has been a sustaining of the two party system for while each party might pretend to offer something different, there is little in way of real differences being articulated.
One thing that we must not ignore is the voting system that we have in the United States. Our use of the "winner-take-all" system of elections that we use.
In many other countries, a system called "proportional representation" is used. This means that parties are represented in a parliament in proportion to the percent of votes they receive in an election. In such a system, a party that won 25% of the vote, for example, would get about 25% of the seats in the legislature.
In the US, a party that won 25% of the votes in an election would likely get 0% of the representation (unless there were very odd circumstances with a large number of candidates splitting the vote). In such a system, third parties will have a tremendously difficult time breaking up the two-party system. Small parties cannot win any seats until they are able to win a plurality in a given district. This makes it hard for "third parties" to get going and helps to maintain the two-party system that we have.