What is the purpose of air that passes through the engine core in a turbofan engine? Is it mainly to spin the fan rotor?
The core is the Internal Combustion Engine - it has intake (of air), compression (of air), combustion (of the fuel/air mix), and exhaust (water vapor, CO2, air) that provides the motive force to rotate the turbine (N2) and provide perhaps 25% of the actual thrust of the whole engine when it exhausts out of the tailpipe.
From How Do Jet Engines Work? on this same forum, we get this diagram to aid us:

This core may also provide the motive force for electrical generators, hydraulic pumps, bleed air, ant-ice etc. (it would be inefficient and make no sense to get these from the fan air).
The thus driven turbine via it's shaft rotates the compressor blades at the front/intake of the core thereby completing a loop and making this cycle self sustaining as long as there's fuel to feed the engine.
The turbine rotation and the compressor rotation and the flow of air so induced also make the fan (bypass) part of the engine rotate (N1) through aerodynamic coupling. Thus the fan cannot function without the core, but the core can function without the fan.
So, yes, the objective is to drive the fan rotor, because the fan rotor by itself is not an engine and cannot self-rotate with purpose of producing thrust, but it is a device that can be driven by an engine  to produce thrust, around 75% of the total thrust of a typical combination.