They only need them while they in Afghanistan. All the east and south east border of Afghanistan is with Pakistan. To ship equipment in and out of Afghanistan they need to do it through Pakistan. All other routes are impossible or very expensive and unlikely. e.g. the border on the west is into Iran and I don't think they would be in the mood to assist America.
Also, by buying friendship with Pakistan they were hoping they would get some assistance in stopping alquaeda and the taliban from slipping across the border into Pakistan when under attack and then slipping back into afghanistan when the heat died down. It costs the US billions in aid to Pakistan to try and get this cooperation and it was money poorly spent. It appears that Pakistan does just enough to look like they are on side and no more. Consequently, Osama bin laden was found living in pakistan in an army town very close to army facilities.
America is obviously aware of the situation but what else can they do but continue to pay up. ?