Zanzibar has two rainy seasons. The long rains (mid-March to late May) close many hotels on the island; the short rains (November) are less disruptive but still wet. The high seasons are accordingly June to October — dry, breezy, cooler nights, the best time for the sea — and late December to February, hot and humid but reliably sunny.
Within those windows, two dates are worth aiming for: the ZIFF film festival in early July fills the Old Fort and Forodhani with screenings, concerts and dhow races; and the Sauti za Busara music festival in February is one of the best contemporary African music programmes on the continent.
Avoid Eid week and Ramadan if you are after the bars and the open kitchens — the city quiets down considerably, restaurants restrict their daytime hours, and several bars close for the duration. Stone Town itself is enjoyable in any season; the weather mostly determines whether you also go to the beaches afterwards.