I second this. The terminals on it corrode also. If the 2 power wires lose connection, the switch loses also. If terminals are too dirty to clean, replace them.Check the starter relay that sits just in front of the battery... if that goes bad, then pretty much the entire bike is "dead"... and if you tap it (or jump it) then that may explain why the problem goes away temporarily.
That relay wears out; someone on here recently found a Cracked Case to the 30amp fuse on the front of that relay causing same symptom; Check the 30amp fuse too... it may be bad or loose.