There isn't a right or wrong decision what you should work on. It's entirely your decision, taking into account both your own passions and interests, and the likely rewards of succeeding at solving different types of problems. It's certainly the case that not all problems are created equal in how highly they are regarded by the mathematical community, and how much solving them will advance your career in a practical sense.
In any case, you might consider that if you decide to do a bit of "pandering" to advance your career, you will be in pretty good company. Gauss was twenty-four and already well-known for his amazing discoveries in number theory when he decided to work on an applied problem in astronomy: calculating the orbit of the dwarf planet Ceres, which had been discovered at the beginning of 1801 and observed for a brief period but then could not be located again by astronomers. The problem of finding Ceres became quite a trendy topic that attracted the attention of the scientific community of the day. Drawn by the opportunity and interest generated by this problem, Gauss attacked it and, through heavy calculations combined with ingenious methods he had developed, was able to calculate the orbit of Ceres and predict its future position from the recorded observations. This was a stunning success: astronomers pointed their telescopes towards the positions Gauss predicted and swiftly located Ceres.
In chapter 14 of his classic book "Men of Mathematics: The Lives and Achievements of the Great Mathematicians from Zeno to Poincaré", author Eric Temple Bell describes Gauss's motivations for working on the problem of the orbit of Ceres:
His friends and his father, too, were impatient with the young Gauss for not finding some lucrative position now that the Duke had educated him and, having no conception of the nature of the work which made the young man a silent recluse, thought him deranged. Now at the dawn of the new century the opportunity which Gauss had lacked was thrust at him.
[...]
Why not indulge his dear vice, calculate as he had never calculated before, produce the difficult orbit to the sincere delight and wonderment of the dictators of mathematical fashion and thus make it possible, a year hence, for patient astronomers to rediscover Ceres in the place where the Newtonian law of gravitation decreed that she must be found—if the law were indeed a law of nature? Why not do all this, turn his back on the insubstantial vision of Archimedes and forget his own unsurpassed discoveries which lay waiting for development in his diary? Why not, in short, be popular? The Duke's generosity, always ungrudged, had nevertheless wounded the young man's pride in his most secret place; honor, recognition, acceptance as a "great" mathematician in the fashion of the time with its probable sequel of financial independence—all these were now within his easy reach. Gauss, the mathematical god of all time, stretched forth his hand and plucked the Dead Sea fruits of a cheap fame in his own young generation.
Bell proceeds to describe the rewards that Gauss reaped from his feat:
Recognition came with spectacular promptness after the rediscovery of Ceres. Laplace hailed the young mathematician at once as an equal and presently as a superior. Some time later when the Baron Alexander von Humboldt (1769-1859), the famous traveller and amateur of the sciences, asked Laplace who was the greatest mathematician in Germany, Laplace replied "Pfaff." "But what about Gauss?" the astonished Von Humboldt asked, as he was backing Gauss for the position of director at the Göttingen observatory. "Oh," said Laplace, "Gauss is the greatest mathematician in the world."
Of course, Gauss is only one of numerous mathematicians whose choices of what to work on were influenced by considerations of career success. Was Gauss's decision to work on an applied problem really "pandering"? Did it "defeat the purpose of doing mathematics"? I'll let you judge for yourself.