Can’t find or hire f/t employee.
Need specialized skills.
Only need someone for limited time.
Don’t want to pay employment taxes and benefits.
Get around hiring freezes and quotas.
End run around management, or cover-their-ass move (put blame on outsiders rather than employees).
It generally is that simple. Freelancers fill roles to help complete tasks or build features that the company doesn’t need full time employees for long term.
Consultants are brought in to educate or fill specific knowledge gaps for a team.
Consultants can also be used to enact managements wishes with some separation.
With employees, it's similar too. At some companies, the policy is FT employees don't leave. Onboarding, trust, training, team building is all expensive.
But sometimes you need people in fast to do a job. And some people aren't fond of the don't leave lifestyle. So there's a niche for contractors. Some even get "refactored" into FT employees.
There can be a circular dependency too. There's no budget for a product that may not succeed, but the product will not succeed without people working on it. Contractors are usually the quickest fix for that.
If you do this with full time employees and the project is canned, then you have to do layoffs or realign all the employees to different teams.