The value of gravitational attraction moves the spring up and down, allowing for the spring to oscillate. The reason it doesn't affect the period of the spring is because gravity is a constant force that doesn't change the overall energy of the system.