Answer:
WHY is the Earth's axis tilted at 23.5 degrees to the ecliptic? We don't know for sure. All rotational motion is "conserved" when masses converge; for example, the rotation of everything in the solar system (with only a couple of exceptions" is counterclockwise as seen from a point far above the North Pole. All the planets orbit that way, the Sun rotates that way, and all but two of the planets rotate that way. We suspect (but ar not CERTAIN) that this is because this is the direction that the primordial planetary nebula was spinning before it collapsed to form our Sun and the planets.
But collisions can change things, and early in its history, w believe that the Earth was involved in a MASSIVE collision - when a planet possibly as big as Mars collided with the Earth. We believe that the mass ejected from the collision formed the Moon. But it also would have changed the rotational pattern of the infant Earth, and is probably responsible for the spin, and tilted axis, of the planet we live on today.
We're not certain; it was more than 4 billion years ago.