For scuba diving this practice has no use. as you will be under water for a while and will be breathing compressed air from your cylinder.
In the old days people used this for free diving / skin diving /snorkeling to be able to hold breath for longer. I do not want to go into long discussions why this works, but in layman's terms it suppresses the bodies urge to breath by lowering the Carbon dioxide in the blood, which is the main trigger for breathing.
Hyperventilation is no longer considered safe even for free divers.