Photo by Deb Harding from the Hay-on-Wye website
The festival is a 10-day annual event that attracts 85,000 people from around the world who come to participate in some 500 events that take place in the tented festival village in late May - early June. What started out as a festival on the border between Wales and England grew to international proportions and now there are thirteen locations worldwide holding festivals of their own throughout the year. The official Hay Festivals website has plenty of information about all the events but if you want to visit the original festival in 2012 plan to be there May 31st to June 10th and to prepare visit the town's website, they have plenty of information on accommodations, attractions and activities to occupy your time outside of the festival.
If you don't like crowds, want to have your choice of lodging and prefer to quietly browse Hay's many bookstores there's plenty to do the rest of the year as well and judging by the photos online the town and the nearby areas are absolutely lovely and worth visiting. Here is an interesting article on the NY Times website by a writer who visited the area 2 months before the festival and it sounds like she and her husband had a wonderful time. The article was written in 2006 but I'm sure the spirit of the town and the people hasn't changed too drastically.