The weather of Cabo San Lucas is the reason why it attracts hordes of sunbathers all around the year.
The best time to visit Cabo San Lucas would not depend on when you would get the best weather (since that is a year-round gift), it would actually rely on when you will not have to deal with crowds of zealous tourists. And that time would be from May to June when the winter rush has subsided.
Truthfully, even though you might find the beach town crowded at this time, October and November are also good times to visit Cabo San Lucas. Just make sure you make your hotel and flight reservations way in advance.
Cabo San Lucas is hurricane prone and hurricanes get rain with them. Otherwise, this place is less rainy than neighboring San Jose Del Cabo.