They provide a very important mechanism that allows for the main party to fail in a way that it otherwise couldn’t. The only way for a “good” (according to the constituency) idea to succeed is if the “bad” ones fail. If bad ideas are prevented from failing, then the efficiency of the entire system declines.
In the two party system, the only ways for a party to fail are via apathy (not bothering to vote at all), and total defection to the other side. The small party allows voters to signal to the main party that they are failing to adequately represent certain elements of their constituency. It forces the main parties to consider all the components of their base, otherwise they’re can safely abandon them to some extent while they fight over the middle.
It’s arguably less efficient in the US due to an electoral structure that’s quite unfavorable for small parties, but it still serves an important purpose. It doesn’t make sense if you only look at one single election, but the election is the most important feedback mechanism in a democracy, and they typically happen rather infrequently. So you can look at one election, and conclude that a minor party cost one side a particular victory. But if the loser decides to examine why they lost, there’s a clear incentive to improve how they represent their constituents next time.
It’s not highly efficient, but no democracy is. Perhaps the US more than some others, but even if you look at the worlds ‘direct democracies’, you couldn’t conclude that asking the public a handful of extra yes/no questions every year is perfectly efficient either.