What is the main function of high and low gain antennas?
Do all satellites and space probes have high and low gain antennas?
First of all, not all satellites have both high gain and low gain antennas. Most inexpensive LEO satellites only have one, depending on the bandwidth requirements. This isn't an issue, as the satellites are so close to Earth that the link margin is considerably improved over further out.
As you get further away, you start to have more demanding RF requirements, due to the fact that you are much further away, and might need a higher gain antenna to accommodate the extra distance. These higher gain antennas will require a higher pointing accuracy. As you start to have a very small beamwidth, it becomes more important to have a back up method to communicate with the satellite in the event of an extreme off pointing of the primary antenna. This signal will be a much lower bandwidth than the high gain, and also can't take the full bandwidth receiving that the high gain can take, but it is something. Hopefully you've designed the system such that you can figure out from the limited data what's going on, and uplink the right commands to fix the satellite. In other words, low gain antenna are a contingency that you can't point your high gain antenna correctly.
There are a couple of different uses. For looking at incredibly small radio sources, the idea of a high gain antenna is that it can detect smaller signals - effectively 'gain' is a type of amplification.
(As a quick example, your home wifi network - typically it is broadcasting at 100mW and you might be able to get decent reception round your house, or possibly in your garden, with the standard antennas fitted - usually 3dB. You can use the same wifi router to communicate over miles using a high gain antenna - eg 20dB - as it will put out a larger signal, and detect smaller signals, but is usually much more directional)
Low gain antennas are typically used for communication with the Earth, as relatively speaking, signal strength from the Earth is massive compared to the incredibly weak signal from a stellar source.
As @DeerHunter points out, you also use both types of antenna for comms. The high gain is very directional, so as long as the satellite attitude control is good, you can point it directly at the base station and communicate, A low gain antenna is generally much more forgiving of direction, so if the satellite drifts, you can send adjustment commands to the low gain antenna - at lower data rates.