Does the end of the wire have a female plug? It should. There should be a male spade on top of the limit switch. Plug it in there. I remember the hasle of securing this wire in my garage door days, allways a pain. It should just press into the top of the channel, psess firmly. Make sure there are no nicks in the wire. The reason it came out is most likely poor installation.
Remember that overhead doors need periodic maintenance. You are working them as hard as your vehicles and they can be just as dangerous. Make sure you can open and close doors manually, they should be balanced throughout its' travel. Test your eye-sensors and put a 2x4 under the door, it needs to open when it hits it. Look for: bad rollers, tighten loose nuts, frayed cables, broken springs and NEVER TOUCH THE TORSION ASSEMBLY. I have seen the aftermath and it is not pretty.