There are basically three questions:
1. Why is Obama hitting PA?
2. Why is McCain hitting Iowa?
both campaigns are aware that polling is fluid and that anything can happen. They can't spend too much money in individual markets - they need to be ready in the event that some dynamic of the race changes. If Obama screws up in the debate PA could become competitive - some change in the world economy or Iraq, etc. could alter the race and it would be foolhardy to move out of states on the cusp with large numbers of EV's too soon.
McCain in Iowa is also partly for perception. To give up on a state won by Bush in 2004 would look bad. But keeping Iowa could also preserve him the election if he holds onto NV, OH, VA, FL. He has to compete SOMEWHERE.