We are flying into Heathrow and plan to take the National Express for our flight out of Gatwick. Is it necessary to book in advance? If so, how much time should we allow to go through customs and get to the bus stop from Terminal 5?
You don't have to book in advance. And it's hard to fix a time to go through customs. Sometimes it's a short wait and sometimes it's a long wait. But once through, just look for the signs to the bus stops.
Customs usually only takes seconds, unless you are unlucky enough to have your bags searched, it's immigration that may take the time, depending on how many planes land in a short space of time and how many immigration officers are on duty.
Make sure that you don't wind up very stressed in this moving from airport to airport.
I hope you have plenty of time.
You don't say where you are going, to/from, with these airports although there is a hint that you are going through immigration at Heathrow.
You also don't say when the transfer will be.
The coach will use the M25 outer London circular motorway. When everything is screaming along it will take a car an hour or so for the drive, a coach will take longer; the M25 is notorious for creeping along, especially at rush hour, and on weekends, and various other random times.
Your outbound flight from Gatwick will need you there 3 hours prior for an international flight, a bit less for a domestic flight.
If you could provide a touch more detail I could give a more specific answer, complete with coach times.
Will you also be collecting checked luggage? Even if you don't plan to, you have to allow for the possibility that the airline will required some carry-on sized bags to be checked at the gate, due to space hogs (a.k.a. hogs from space). As a very general rule of thumb, I try to allow one hour to collect luggage and one hour to navigate immigration and airport terminals. That's generous, but not generous enough to cover a flight that's really late.
The IATA minimum connection time is 3.5 hours, but that hasn't been changed for decades and many airlines won't sell connections with less than at least a further hour. If on separate tickets even more time might be advisable, depending on time of travel.