What does this mosfet switch circuit do?
It's battery reverse polarity protection like this circuit: -



When the battery is connected correctly, the PMOSFET turns on and acts like a low ohmic path for current to the load. If the battery is reversed, the gate is higher than the source in voltage and the PMOSFET does not turn on thus, it "protects" the load.

The gate resistor is optional and is not needed for batteries of lower voltage than typically 10 to 15 volts but if the battery were 15 volts or more, the resistor AND an added zener diode would protect the gate-source region getting too much voltage and breaking down: -



It's probably a good idea to have a resistor anyway because it does offer some ESD protection to the gate (that would otherwise be directly connected to a battery terminal and could be vulnerable).