I was imagining the possibilities of creating a ship mast which could not get struck by lightning. Is there a material it could be made of that would never get struck by lightning?
It's not the material per se which makes it lightning proof, but rather what's around it.
When a difference of potential starts building up, sooner or later it will cause a discharge and produce the lightning.
The discharge happens at the point which offers the least resistance to the discharge current flow. Therefore in a world made of gold, a wooden stick is almost sure to never get a lightning (unless it gets close enough to the other pole...).
Even in a world made of vacuum and only your perfect pole, a lightning would happen, because you can't store infinite energy in a finite volume.
I think there are two main physics principles to consider.
The conductivity of the material. Typical sailing masts are wood, which is generally considered an insulator. However we know that lightning will hit trees and wooden masts. Electrical potential is a lot like water pressure in some ways. Normally glass stops water (like wood stops electricity), but at firehose pressures water breaks through. If the potential is high enough, an arc will go from the clouds to the ground.
The geometry of the mast. Charges build up on the surfaces of objects, and the tighter the curvature of the surface, the more charge density you can get. (I am using a lot of improper terms here because its been a while since I studied electrical engineering.) So if you have a sphere, the charges will be spread around the surface pretty evenly. If you have a spiky ball, the spike tips will be more strongly charged than the sides of the spikes. The places of high charge density are more likely to arc. In the case of a ship, the mast is a really big spike. On the ground, trees are big spikes.
So, I think the best you can do is 1) use smoother, less spiky geometry where you can, and 2) make a lightning rod that is spikier than the mast.
Make your whole ship out of a resistor
Sure, you could go the boring, so-called "practical" route (yech) of installing a lightning rod. But why do that when you could instead make your entire ship out of paraffin wax, fused quartz, PET, or Teflon? Sure to turn heads, and a great conversation-starter!
You see, lightning takes the path of least resistance to the ground or water. Steel, aluminum, and wood are better conductors than air, which is why lightning prefers to travel through those when it can, rather than through the air. So all you have to do is make your mast (and, for good measure, the rest of your ship) out of something with a higher resistivity than air. Lightning will take one sideways look at your plastic ship and go the long way around.
This table tells us that air has a resistivity of 1.3×10^16 to 3.3×10^16 Ω m. Selected entries from the table:
Aluminum 2.82×10^−8 Titanium 4.20×10−7 Stainless steel 6.9×10^−7 Wood (damp) 1×10^3 to 4 Wood (oven dry) 1×10^14 to 10^16 Air 1.3×10^16 to 3.3×10^16 Paraffin wax 1×10^17 Fused quartz 7.5×10^17 PET 10×10^20 Teflon 10×10^22 to 10×10^24
No, yes, kinda...
If the potential difference between two ends of a length of material is great enough, it will conduct electricity. It doesn't matter what it is. However, the nature of the material may be that it melts, burns, or explodes when that happens. So when you ask the question, "is there a material lightning does not strike?" the simple answer is "no."
However, you can't always control what's around the object. In other words, if the base of your ship's mast is made of metal and for some weird reason that metal extends through the ship to touch the water below, the metal at the base of the mast becomes a great place for lightning to strike and topple the mast.
Except! Your ship is on an ocean of water and pretty much anywhere is a better place for lightning to strike than the ship, itself. It's a common misconception that altitude alone makes something significantly more susceptible to a lightning strike. That's true only if there's a better conductor to ground than every where else. Thus, a wet tree in a rain storm is a little closer to the potential discharge than the surrounding grass and is therefore more likely to be hit.
But change that to a tree on a 10 square-meter island in the middle of a massive lake and the odds of that tree being hit drop tremendously because the surrounding water represents a better conductor than any amount of water on the tree.
Keep in mind that lightning striking the masts of sailing ships are kinda uncommon. Modern statistics say the odds are four out of every thousand strikes during rough weather. Those are low odds. But as the linked article explains, it's still valuable to do something to mitigate the effects.
In other words, you don't want to try to make your mast a better insulator, you want to do something to make your mast a better conductor, so when the lightning does strike it goes exactly where you want it to and discharges in a much safer manner.
But if you insist that you want a better insulator, avoid rainy weather. It's the only way to solve the problem. Water is a more than satisfactory conductor.
Another alternative is keep your mast metal, but make it actively charged via Van de Graaf electrostatic generator or similar.
The lightening happens because electrostatic potential levels of clouds and ground (or sea) are different. When that difference (i.e. voltage) becomes high enough, even the things that are usually not conductive become so due to dielectric breakdown, and electricity flows from one potential level to the other, until they equalize.
As other say, which path is preferred depends on its conductivity, and solutions offered so far focus on reducing that aspect.
However, another alternative is making your mast at the same charge as the clouds. That way it won't be interesting target for the lightening which wants to reach opposite polarity charge (just like the lightning that has started from cloud potential towards ground potential does not decide "ok let's get back to the same place in cloud where I started" - there is no reason why it would go back to the same electrostatic potential).
Of course, it would use energy, and you must watch you do not overcharge it, as otherwise you could create your own lightning from your mast to the sea (even in the absence of the storm outside).