Hi,
If you look at NMOS (with gate connected to vdd), it has a very low RON for low input values and RON increases as the input increases. Similarily PMOS (with gate grounded) has low RON for input voltages near vdd and RON increases as input voltage decreases.
So when you use a transmission gate with nmos and pmos in parallel, by appropriate sizing you can have a small RON across wide input range, thus effectively acting as a (close to) ideal switch.
Hope it answers your question