Not legally mandatory.
Lenders may require one.
Barring buying a new house off-plan, I personally think you're taking a big risk if you don't have one- for a newish house, a simple or mid-range homebuyers type should be sufficient if it isn't of unusual construction. And if you're buying an old house, say, pre-1960s, or anything of 'non-standard' construction, or in an area prone to problems like subsidence, it's seriously bonkers not to have a more detailed one- I go for the equivalent of the old 'full structural survey'. Rule of thumb- the older the house, the more detailed the survey needs to be.