A concern in a bathroom is that there could be a water spill, so it is a good idea to use an underlay which is resistant to spills. Although a little water is not likely to damage any of the three main types of underlay, crumb rubber underlays are particularly resistant to water damage. For this reason, if putting a carpet into a bathroom, two excellent options to consider are System 10 or Treadmore. System 10 is the thicker and more comfortable of the two.
If putting wood or laminate into a bathroom then consider using an underlay with a vapour barrier, as this could also help if there is a water spillage.