Solar dynamics and its effects on the heliosphere and earth