When presidential candidates travel the country in the year leading up to the election, they don't hit every single city in every single state. It would be impossible. Campaign coordinators plot out the campaign based on the most important states for the candidate to show up in. If a state has voted Republican in every election for the last 40 years, then the Democratic candidate would just be wasting his or her time giving speeches there. The Republican candidate would be, too, for that matter -- why bother stopping in a state if it's going to vote for you no matter what?
Campaigns do visit non-swing states, however, and the reason is simple: money. High-priced campaign events can raise millions of dollars, which will ultimately pay for campaign advertising in other, more important states.
When it comes time for making speeches, shaking hands and kissing babies, swing states get all the action. If a state was decided by a few thousand votes in the last election, it's easy to see why it's important to give several campaign speeches around that state, each one delivered in front of several thousand, potentially undecided voters. If you add news coverage, word-of-mouth and poll momentum (the tendency for undecided voters to vote for whichever candidate is leading in the polls), a campaign speech in a closely contested state can make a huge impact on election night results months later. The closer the state's margin, the more important the campaign speech.
Just being a swing state isn't enough to bring a state to the top of a candidate's campaign itinerary, however. Since electoral-vote apportionment is based on population, some states have more votes than others. The states with the most votes get the most attention. Why make speeches in three states with five electors each when you can make one speech in a state with 15 electors?