Thunder is the sound of a shock wave of hot air produced by a flash of lightning. Many people measure the distance of the lightning strike by counting the seconds from when they see the lightning to when they hear the thunder. The number of seconds is a rough way of guessing the distance in miles.
Thunder cannot occur without lightning, so if you hear thunder then there will have been a flash of lightning somewhere, probably hidden by the clouds. If you see lightning and do not hear thunder this is because the sound of thunder is quickly absorbed by the air.