I'm not sure exactly why It's tilted vertical by 23.5 degrees. All I know is the earth is tilted to give us the seasons. If the axis were vertical, the sun would be overhead at the equator and we would have the equivalent of the vernal equinox in the northern hemisphere and the autumnal equinox in the southern hemisphere. Day and night would be the same length and there would be no summer or winter, just spring and autumn all year round. If the tilt was horizontal, the sun would be overhead at one pole or the other, giving us either eternal summer or eternal winter, depending on which way the axis was lying. So the earth is perfectly tilted so we can enjoy all four seasons.