From an excellent Wikipedia Mercury Article
Mercury's orbit is inclined by 7 degrees to the plane of Earth's orbit (the ecliptic), as shown in the diagram below. As a result, transits of Mercury across the face of the Sun can only occur when the planet is crossing the plane of the ecliptic at the time it lies between Earth and the Sun. This occurs about every seven years on average.
I appreciate that the investigation of the formation and history of the solar system is still very much an open topic, so there may not be a simple answer as to why Mercury has such a highly inclined orbit.