The purpose is to equalize the amount of tax that companies pay. Consider the following example: Assuming a tax rate of 30%, Company A has net income (profit) of $100 in year 1 and $100 in year two pays $60 in tax on a total profit of $200. Company B has a net loss of $100 in year 1 and net income of $300 ni year 2 has a total profit still of $200. Assuming loss carryforwards are allowed, Company B pays $60 in tax still. Without loss carryforwards, Company B ends up paying $90 in tax on the same amount of profit.
It leads to bad headlines when companies claim a bunch of loss carryforwards, but it actually is a fair practice. The other thing to keep in mind is that losses are only paid out in refunds when you actually pay tax. Company B does not earn $30 back from the government for losing money in year 1, it instead gets money back once it starts making profit.
Note that at least in Canada, these rules apply to all types of income, not just business income, although losses on employment income basically never happen.