This landmark case came out of the bitter political dispute between the outgoing Federalist Administration led by President Adams and the incoming Democratic-Republican Administration led by the new president, Thomas Jefferson. After going down to defeat in the 1800 election, the Federalists wanted to stymie the Democratic-Republicans' legislative agenda by packing the judiciary with their appointees. One of these men was a man called William Marbury.
Unfortunately for him, he didn't receive the letter confirming his judicial appointment in time, so he wasn't given his promised position as judge. Incensed at being deprived at what he considered was rightfully his, he sued the new Administration, in the person of the Secretary of State, James Madison.
The Supreme Court had to maintain a very delicate balance in this case. It consisted overwhelming of Federalist supporters of the outgoing Adams Administration. And though they were inevitably hostile to the new government, the justices of the Court recognized that if they displayed overt partisanship in reaching their decision, then the Democratic-Republican controlled Congress would almost certainly clip its wings.
So in his landmark decision, Chief Justice Marshall cleverly gave with one hand, but took with the other. Marbury would not be awarded his judicial commission, despite the actions of the new Administration being unlawful. In handing down this decision, the Court was invalidating the statute which had given it the power to decide this case in the first place. So on the face of it, although the Administration had won the case, at the same time the Supreme Court had given itself the power to strike down legislation it deemed unconstitutional, the power of judicial review, which it has held ever since.