It was necessary to maintain the independence of the Special Prosecutor.
Fortunately, Attorney General Richardson's resignation letter is easily searchable on Google. In his letter, he explains that he made several commitments and pledges not to interfere with the work of a Special Prosecutor. When Nixon demanded he fire the Special Prosecutor, that would be interfering with the work of the Special Prosecutor, which directly conflicted with those commitments and pledges. There was simply no way to follow his commitments to both his boss the President and the American people. So he quit.
Dear Mr. President:
It is with deep regret that I have been obliged to conclude that circumstances leave me no alternative to the submission of my resignation as Attorney General of the United States.
At the time you appointed me, you gave me the authority to name a special prosecutor if I should consider it appropriate. A few days before my confirmation hearing began, I announced that I would, if confirmed, "appoint a special prosecutor and give him all the independence, authority, and staff support needed to carry out the tasks entrusted to him." I added, "Although he will be in the Department of Justice and report to me--and only to me--he will be aware that his ultimate accountability is to the American people."
At many points throughout the nomination hearings, I reaffirmed my intention to assure the independence of the special prosecutor, and in my statement of his duties and responsibilities, I specified that he would have "full authority" for "determining whether or not to contest the assertion of 'Executive Privilege' or any other testimonial privilege." And while the special prosecutor can be removed from Office for "extraordinary improprieties," I also pledged that "The Attorney General will not countermand or interfere with the Special Prosecutor's decisions or actions."
While I fully respect the reasons that have led you to conclude that the Special Prosecutor must be discharged, I trust that you understand that I could not in the light of these firm and repeated commitments carry out your direction that this be done. In the circumstances, therefore, I feel that I have no choice but to resign.
In leaving your Administration, I take with me lasting gratitude for the opportunities you have given me to serve under your leadership in a number of important posts. It has been a privilege to share in your efforts to make the structure of world peace more stable and the structure of our own government more responsive. I believe profoundly in the rightness and importance of those efforts, and I trust that they will meet with increasing success in the remaining years of your Presidency.
Respectfully,
ELLIOT L. RICHARDSON
Though I was unable to find Deputy Attorney General Ruckelshaus' resignation letter, it is not a stretch to assume the reasoning is the same.