There are many accommodation options in and around Newmarket, if you wish to stay the night in the beautiful market town prior to the race. It is generally considered the birthplace and global centre of thoroughbred horse racing, and a future UNESCO World Heritage Site. The Newmarket Race Courses website lists a number of options (although it will be possible to find other options through a quick search online).
At the end of the race, if you wish to transfer yourself almost immediately to a shower and bed, a number of accommodation options can be found in and around Manningtree.
A wide range of accommodation options can be found on the following websites: Suffolk Tourist Guide, Visit Suffolk, and Visit Essex.