They stabilise the lamp current and thus lamp power. The rating of the ballast is important to ensure proper lamp operation.
In the case of low-power (150 W) metal halide lamps especially, an excessive temperature rise can occur in the ballast at the end of lamp life. The ballast should therefore always be fitted with overtemperature protection.