A lot of the time it comes from the weather head or the electric meter. If those two exterior items are not properly installed or properly sealed, then water gets into them, runs down the service wire, and then eventually into the electric panel.
Another thing that happens is the area that the panel is in is damp. High relative humidity can cause rust to occur in the panel. While there is not usually active water in the panel, the rust makes things not work as well.
Be sure to have your electrical system properly inspected. Contact me today!