This law was necessary, in the minds of its supporters, because government was becoming too corrupt.
Before the Pendleton Act, government jobs were all given out as "patronage." That means that the elected officials would have the opportunity to appoint all government officials instead of having them be selected because of merit. In such a system, government jobs were handed out to people with political connections or people who paid bribes to politicians. This seemed to many like a corrupt system and they wanted to reform it by making government jobs be filled on the basis of merit.