There are at least three reasons why we might argue such legislation is necessary.
First, it can be seen as economically important. Pork barrel legislation brings real economic activity to various Congressional districts. This can be very beneficial to the economies of those areas.
Second, and relatedly, pork barrel spending helps people to feel that the government is actually working for them. When projects are undertaken in a particular area, people see that their tax money is being used in ways that help them. This makes them have a more positive attitude towards government. This can be seen as necessary because it helps build support for government, which helps keep our system stable.
Finally, pork can be seen as necessary for the functioning of Congress. By giving out pork, party leaders are able to persuade legislators to back certain proposals they might not otherwise support. We can argue that a system without pork would be one in which it would be harder to get any deals made. This would add to the gridlock we sometimes experience in our current system.