In this example, the meaning doesn't really change whether you use "an" or "the".
In principle, "the ability" means one specific ability, while "an ability" means an unspecified ability. But in this case, it doesn't really matter whether you're talking about a specified or an unspecified ability. It doesn't change the sense.
Addendum in Response to Comment
If I said, "Mike has the ability to make money", the use of "the" means that there is just one such ability. But if I said, "Mike has an ability to make money", the use of "an" means that there is more than one ability under discussion. I might mean that there are many different abilities that might enable one to make money, like one might be a good business manager or one might be a good engineer or one might be lucky at gambling or whatever. Of these many different abilities that one might have that enable him to make money, Mike has one of them. On the other hand, I might mean that there are many abilities out there, the ability to run fast, the ability to make friends, the ability to be a good father, etc, etc. Among all of these abilities, one of them is the ability to make money, and that's the ability that Mike has. (I might also be thinking both: that there are many different abilities that enable one to make money, and there are many other sorts of abilities also.)
Depending on context -- whether I use "the" or "an" and which possible meaning of "an" I am thinking of -- might or might not really make a difference to what I am trying to say. If my point is simply that Mike is good at making money, and I go from saying he has this ability to talking about how much money he has made and what he does with the money, then it probably doesn't matter which of the three possible meanings I had in mind. Frankly, it's likely that I wouldn't even think about it. On the other hand, if my point was to discuss different abilities that would help one make money, if I was trying to say, "Mike has an ability to make money, and Bob has a totally different ability that also enables him to make money", then my word choice would be more carefully chosen.