The obvious answer is during the summer. Tourists usually come in the months of July and August, but you can avoid some of the tourist jam if you come in the spring, for example. It’s not as hot as in the summer but it’s usually warm enough to go to the beach, have a swim and indulge in watersports. September is also good because it’s still hot but there are not as many tourists either.
Most of the rain tends to fall from November to February, but having said that you could get a whole month of sun and blue skies - we did recently in December and January! I suppose the worst time from a restaurant and atmosphere point of view would be between November and March. Some towns like Nerja have activity all through the year.