"May" carries the sense of permission, of courtesy, and of uncertainty, depending on context.
"Can" carries the sense of ability, possibility, and potential, depending on context.
Examples:
"I can swim." (I am able to swim.)
"I may swim." (I haven't decided yet if I will or not.)
"I may get good grades." (I'm not sure yet, but there's a chance of this.)
"I can get good grades." (I know it's possible--perhaps I have done so before.)
"He can be nice." (He is known to be nice sometimes.)
"He may be nice." (It is uncertain whether or not he will be nice.)
"It can rain at any time in the jungle." (Rain is always a possibility.)
"It may rain today." (There is an uncertain chance of rain.)
Note: It would be grammatically incorrect to say "It can rain today" if one meant to say there was a chance of rain. Saying "It could rain today" would be more correct. "It can rain today" would mean that the speaker is willing to have the rain, perhaps is prepared for it (and may or may not have been ready for rain earlier), and is nearly a challenging statement, inviting the rain.
Grammatically, the words "can" and "may" are almost always interchangeable; but the meaning will change as well.