This never really made sense to me. Couldn't it allow a president to effectively nullify a law he considers unjust, by pardoning anyone convicted of violating it? If this could happen, why hasn't it?
It's a classic hedge against imperfections in the criminal justice system as well as a "check and balance" against the power of the legislature and judiciary. If a President abused such a power too greatly they would be met with a completely intransigent legislature, who would consistently bypass the authority of the president in making laws, for example.
The reason it was included in the constitution is likely significantly due to English tradition, which included such a power to pardon going back to Anglo-Saxon times. Partly this was because the law in those times was very inflexible in regard to things like homicide, so the "out" was to give rulers the power to grant clemency, though it had other uses as well. At the time of the founding of the US these powers would have been familiar to the framers of the constitution. Note that many state governors had the same power both before and after the revolution. Consider, for example, this constitution of the Commonwealth of Virginia from 1776 and its grant of the power of pardon to the governor.
That power is usually reserved for the head of state, which is the president.
It is also the job of the executive branch to oversee the implementation of law enforcement actions.
It would be imprudent for the Justice system to be enumerated the power to pardon.
It would be too political for the Congress to be enumerated.
To your second point the president can just issue a directive to not enforce a law that he finds improper. He would then be sued by the congress for a writ of mandamus from the supreme court.