One use of may has to do with permission. The parallel use of can has to do with ability.
"No, Johnny, you may not go skating. The ice is too thin at this time of year." You look at the pond and you think you can skate on it. You can't. You'll fall in.
The confusion comes from the fact that both are used to express potential. It may rain at any time. It can rain at any time. These have very slight differences of meaning because can carries the implication of ability. It may rain today, so I'll take an umbrella with me. The leeward side of the mountains is pretty dry, but it can rain for days on end on the windward side.