If you have a watch with a second hand or a digital watch that has seconds, begin timing as soon as you see the lightning and stop as soon as you hear the thunder start. If you dont have a watch, do your best to count the seconds accurately. Say "One one thousand, two one thousand etc." in your mind for each second.
Every five seconds equals one mile. So if the delay between the lightning and the thunder is fifteen seconds, then the lightning is three miles away. The delay between when you see lightning and when you hear thunder occurs because sound travels much, much more slowly than light. Sound travels through air at about 1100-1200 feet (330-350 meters) per second (depending on altitude, relative humidity, pressure, etc.), which is a little more than one mile per five seconds (one kilometer per three seconds). In comparison, the speed of light is 983,571,058 feet (299,792,458 meters) per second.
For example, if lightning strikes a point 1 mile away, you will see the strike approximately .00000536 seconds after the strike while you will hear it approximately 4.72 seconds after the actual strike. If you calculate the difference between these two experiences, a person will hear a strike approximately 4.71999 seconds after the strike actually occurred. Therefore, 5 seconds per mile is a fairly robust approximation.
Alternative. Since light is so fast you can simply multiply the seconds you counted by 340 to estimate the distance in meters (340 is approximately the speed of sound in m/s, and light is of the order of magnitude of 10^8 m/s so it will not affect your estimate by a meaningful amount) For example: 3 seconds times 340 gives you 1020m and that is even a bit more true than if you would divide 3 seconds by 3 to get 1km (from the previous method).