How to dispel a Genjutsu and why?
Simple answer lies in what is a Genjutsu. Genjutsu is a disruption of your normal chakra flow that makes you experience an illusion as it scrambles your chakra. We have gone through that so you might ask how does this help?
Ok, if a Genjutsu is a disruption in your own chakra flow, to dispel it you need to create a stronger disruption that will clear that one and leave your chakra on its normal state. So basically, there is only one way to dispel genjutsu: disrupting your chakra flow.
Now, this can be done in 3 basic ways:
1- Altering the balance between physical and spiritual energies in your chakra by disturbing your physical energy. This is done by producing pain. Pain comes from the body and thus it makes your physical energy fluctuate. Because of this fluctuation your chakra flow experiences a spike. This spike is a disturbance that will dispel other disturbances present in your chakra.
2- Altering the balance between physical and spiritual energies in your chakra by disturbing your spiritual energy. This is done by your sheer will power. Its done by forcefully creating a surge of chakra in your body by spiking your spiritual energy. It can be done in 2 ways: through a technique named Kai and through other techniques, like Nagashi, that will produce a high enough surge of chakra through your body.
3- Altering your chakra flow through the introduction of foreign chakra. This can be done by an ally or by entering for example, sage mode or being a jinchuriki. The truth is that as foreign chakra enters your system or another energy (natural energy), your chakra flow becomes altered and thus releases from the genjutsu.
All of these produce a reset-like effect on your chakra flow, making it return to normal.
Remember however, that you must always explain why you detected and found out it was a genjutsu in the first place. Some may be hard to detect and not doing so in a logic and reasonable manner deems your release invalid.