Anatomy
Butterflies and moths are both lepidopterans, which means they are of the same large order of flying insects. These insects are renowned for their large, sometimes colorful and often decorative wings. If you've ever held or touched a moth or butterfly wing by accident, you may have noticed the dust that rubs off. Underneath this "dust" are several extremely thin but tough layers of chitin, the same protein that makes up the rest of the moth's body. The "dust" itself is actually scales, which are tiny modified hairs that give the wing its pigmentation and which may aid in flight.
Chitin
Chitin is a tough protein that makes up the exoskeleton of many insects, including lepidopterans like butterflies and moths. Chitin is, by its own thick and dense nature, waterproof. A bead or drop of water that lands on a moth would roll right off. This makes up the bottom-most layer of the wing, making it impossible for water to completely penetrate the wing and allowing for quick drying so that the moth can fly again sooner after being wet.
Scales
The scales of a moth are a little different. These little hairs can sometimes hold back water on the wings, which would interfere with the moth being able to fly. Just imagine the size of a drop of water relative to the size of a moth's wing and the effect is evident. For this reason, moths will often not fly directly after getting wet, instead resorting to crawling using their legs to a safe place and allowing the water to evaporate from the scales. Diurnal moths and butterflies have the advantage of being able to use the sun to aid in this process.
Drowning
Sadly, there are times when the effect of the water is too much for the lepidopterans, and they drown. For example, if a moth were accidentally to fly too quickly into a body of water, and its wings were to become saturated, it may not be able to fly again, because every flap of the wing would submerse it again in water. In this case, the only hope for the moth would be to crawl out of the water and on to solid ground to get dry. If you see a moth or butterfly struggling to fly out of the water, all you have to do is scoop it out and place it on to dry land so it can dry its wings and fly again.