Electricity will take a path of least resistance. When you are inside the car. The electricity goes around the metal shell of the car and to the ground. You can still be harmed by this but it’s not as dangerous as you being hit directly because the electricity is not going through you to reach the ground.
So lightning is similar to the electricity in your house and will flow through metal like wires easily if there are no wires available it will flow through a human body, but that isn’t as easy as through metal. A Faraday cage spreads out the electrical charge on the outside of the metal so the inside is protected, but the external surface is “live”.
Electricity follows the easiest, least resistive path to settle to no energy. For lightning, one of these paths is to the earth. Any object that has better conductance than plain air is good for directing lightning.
Other people have already talked about how the car offers a better path but around your body, so that the lightning doesn’t have to flow through your body.
There can be cases where it could travel through your body, like if you had a leg out of your car, because the rubber tires might not conduct to ground as well as your leg can.
Rubber tires prevent discharge to ground even in petrol trucks, which is why sometimes they have a chain that drags close to the ground used for discharging static electricity through an easier path.
Latest Answers