Heartworms are parasites that can affect your dog (and in some cases you cat). They are transmitted from dog to dog via mosquito bites.
When a mosquito bites an infected dog, it gets the larvae from the infected dog. The larvae quickly develops within the mosquito and when the mosquito bites another dog, the larvae will take home in that new dog. Although some vets say that dogs having heartworm do not need to be treated, some dogs may, in some cases die from heart failure. In other case, the dog can become blind.
This is why it is important to treat your dog with heartworm medicine if you know your dog has been infected, or if there is a big infestation of heartworms in your area (mostly warmer and humid areas, where there are lots of mosquitoes)