Can this setup work. I am new to robotics and raspberry pi. I had the motor lying around previously. What I am trying to get is that when the raspberry pi boots up the motor should start spinning and work as a system fan cooler
If you want the motor permanently running connect it to a 5V and ground pin on the expansion header.
If you want to control the motor (on/off, change speed, change direction) you need to connect it via a motor driver board (or equivalent circuitry). A motor driver board can be controlled by the Pi GPIO and in its turn can control the motor. Suitable motor driver boards can be bought from eBay for a few UK pounds.
It is not safe to connect a motor direct to the Pi GPIO (the 5V and 3V3 and ground pins are not GPIO).