Even if a candidate has no chance of winning the primary, they might win delegates to send to the national party convention, where those delegates get a say in determining the party platform for the next four years. This presumably affects the ideological direction of the party but I'm not clear how.
And as others have pointed out, the presidential campaign is a national platform for spreading the candidate's ideas. The candidate might be able to force the frontrunner to adopt their position, as Clinton was forced to do several times when running against Sanders.
Or a candidate can take advantage the national platform to promote themselves. Candidates often publish bestselling memoirs during their campaign, or leverage their name recognition in to paid positions as "expert" commentators for the 24 hour news networks, as Howard Dean has done, or bigger ratings for their reality TV shows, as Donald Trump will be able to do.