Kiai (in Japanese), Kihap in Korean or simply Yell (in English) has been used for hundreds of years for Martial Arts practitioners all over the world.
In practice, Kiai is done for let out the Ki (Chi) or in English “Inner Energy”, our feeling anxious, helps you to relax the nervous system and helps to prepare and bring together of body, mind and spirit to the technique you perform to get maximum results.
In a real fights it’s used to startle, distract, frighten and intimidate your opponents, express confidence or express victory. It also helps for fighting your own fear and generate more power in your attacks if you ever need to defend yourself in danger.
A kiai can also be used in addition with tightening and strengthen the core muscles to prevent damage to the stomach while you’re being attacked.
So, please do it properly when the instructor asks you to do it.