The mechanism of lightning is the key here.
Lightning that “hits the ground” is actually a current discharge traveling from the ground up to the cloud. Here’s how it works:
Clouds develop a negative charge, which causes positive charge to gathers in the ground underneath it.
Now the air is a great insulator, but the ionized air is a pretty good conductor, and the charge in the cloud ionizes the air around it. This results over time in the formation of a stepped leader, which is a branched formation of conductive channels of ionized air, reaching down toward the ground.
Something analogous is happening on the ground, but the result is called a streamer, not a stepped leader.
When the stepped leader gets close enough to the ground, streamers of ionized air come up from the earth. When a streamer meets a stepped leader, the circuit is complete and the lightning discharge happens along the conductive path, with an enormous amount of charge flowing from earth to cloud in a few milliseconds.
Now to trees, or for that matter radio towers or lightning rods, but in this case trees: as others have noted, trees aren’t actually insulators, though that has nothing at all to do with whether or not it’s raining (rainwater, like distilled water, is practically an insulator). Rather, trees are full of sap which is laden with salts, sugars and is a pretty good conductor.
But none of that actually matters to the lightning discharge itself. At up to 100 million volts of potential, lightning will ignore just about any would-be insulator. But it does mean that the tree will transmit a charge. And remember that positive charge that gathers under the cloud’s negative charge? That will concentrate on the tree, especially the pointy bits that face up. That’s why lightning rods are pointy-to concentrate charge.
Why is that important? Because more charge means more air ionization. Remember the streamer that sets off the discharge of the lightning bolt? That’s a column of ionized air.
So, trees concentrate the positive charge on the ground, favoring the growth of streamers, which then intersect a stepped leader, and WHAM! Lightning Bolt.
The current in the bolt, tens if not hundreds of thousands of amps, can superheat the water in the sap in the tree – if it actually passes through the tree – flashing the water explosively to steam, which wrecks the tree. But sometimes the current passes in an ionized air column around the tree and it just bursts into flame because of the 50,000 or so degree heat. Sometimes nothing bad at all happens to the tree.
The exact same thing happens, by the way, if you are the pointy bit sticking up out of the ground. Especially with an even pointier umbrella sticking up. If you feel a prickly feeling in your head, that’s charge gathering. That’s why the guidance for people caught in the middle of a big flat area when lightning starts, is to lay down flat and be like the ground.
Footnotes