That piece you show not plugged into anything is fine. It is for automatic transmission cars (assuming you have a manual trans car). If you had an auto, you would have a second, similar switch stacked on top of the one you see there connected to the white connector. They both get activated by pressing the gas pedal all the way to the floor, and then when the throttle spool rotates all the way around, it presses up against that metal flap and engages the switches. That's called the wide open throttle or full throttle switch. The one you have enriches the fuel mixture and the additional one on the automatic kicks it down one gear.
Anyway, back to the idle microswitch we were wondering about... you see that bright red plastic splice connector that is on the single wire going to your idle switch? That's been added after the fact by someone and could be part of your problem. See if you can follow what else might be spliced into it and also if it seems loose.