It is not compulsory to get legal representation during an IRS audit. However, consulting a lawyer or CPA agent can simplify the process and improve outcomes in various ways.
For example, the tax professional will organize the needed document before the audit date. Further, they will handle all communications with the IRS so you can focus on your life or business.