Lightning is an electrical discharge from two areas with a large imbalance in charge. Thunder is a sonic shock wave that is caused by air being made to travel faster than the speed of sound.
If you see lightning, then start to count it is possible to work out how far away the eye or nucleus of a storm is. The eye of the storm is the part with the most electrical activity where most of the lightning strikes will take place. The speed of sound is 330m/s and the speed of light is 300,000,000 m/s very roughly 1 million times faster.
This means that when we see lightning the light travels to our eyes almost instantaneously whereas the sound of the thunder in comparison is slow. If we see the lightening and count to three we can say that the eye of the storm is approximately 1 km away. If we repeat this process for each lightning strike, we can tell if the storm is moving towards us or away from us.
If you are safely inside your car or a building this sounds like fun. If you are in an open field and the counting identifies that the storm is getting closer and closer and you can feel your hair standing on end then the air around you is highly ionized or charged. This is not a good sign and could mean there is a lightning strike that may hit soon. A sensible precaution is to squat on the ground with your head between your knees. Try to avoid doing this near metal poles, trees or large bodies of water.