Literally translated as the shallot race, this expression is used in situations of futile competition, when people strive to outdo one another for vain and pointless reasons. It is somewhat comparable to, though less openly vulgar than, the English expression a pissing contest - pardon our French. In a political context, there is often the added connotation of "ugly" or "dirty" race, where opponents would do absolutely anything to win.
In the 19th century, course à l’échalote (or, more rarely, course à l’oignon, onion race) was the name of a game in which a kid ran behind another, holding him by the collar and the seat of his pants, pushing him to run to keep up. The game was called after the vegetable because the term oignon is old slang for buttocks. Shallots being smaller than onions were seen more appropriate for a game played by kids.
The expression evolved in the 20th century to take on a figurative meaning, ridiculing adults engaged in a real-life situation of competition by comparing them to kids running around with their hands on one another’s bottoms.
Note that the vegetable is used with the same figurative meaning in the expression occupe-toi de tes oignons, which means mind your own, well, business. For that idiom, however, linguists offer an interesting alternate origin: in the distant past, in rural parts of Northern France, women were allowed to use a section of the vegetable patch to grow onions that they could sell at the market for their own profit, rather than the household’s. The injunction to take care of her onions might then have been the husband’s charming way of putting his wife back in her place if he felt she was interfering with his own affairs.
Cette campagne présidentielle ressemble de plus en plus à une course à l'échalotte.
This presidential campaign is turning into an one-upmanship to get votes.
Ils se sont lancés dans une course à l'échalotte; c'est à qui aura la voiture la plus rapide.
They started a pissing contest over who has the fastest car.