I have never known anyone to submit a mathematics paper and identify it as having been previously rejected by a journal. (In particular, I have never done this myself, though I have resubmitted over a dozen papers.) If a journal specifically asks for this information, then ethically speaking you should give it or resubmit elsewhere -- I would recommend the latter, since requiring this kind of authorial disclosure is exceedingly rare in mathematics (if indeed it is done at all).
I don't see any benefit to the authors in disclosing a previous rejection. You write
One reason to reveal the history of the paper is that it might be that the same referee will get to handle the paper again. And then there is a good chance of getting a second rejection. By doing this, I can at least make sure that the editors are aware of the situation.
I don't follow why you think that making the editors aware that the same referee previously rejected the paper will help: if the paper and status of the journal are not much different the second time around, then giving the same verdict seems to be appropriately consistent.
Also, in my opinion, that the referee did not seem to understand the paper very well makes it more likely that they were chosen by the first editor somewhat capriciously / randomly / badly, and thus the chance that they will be called upon again is small. Getting a repeat referee is only likely when the referee is one of a very small number of experts in your subfield....but such an expert had better be able to understand your paper, or you have problems well beyond the scope of your question.
For completeness, let me say that I didn't find the argument against disclosure so convincing either:
One reason not to reveal this is that the original journal is not considered "top tier" (and in fact many people raised eyebrows when they heard about the rejection). So by stating that I got rejected from a B-tier journal, I might be shooting myself in the leg.
In my experience, any journal can reject any paper, and the necessary meaning in any one instance of this is infinitesimal. I know many mathematicians who like to tell stories about getting rejected from journal A and then getting accepted by better journal B. Moreover, as I understand the editorial process [I am not a journal editor, but I know some and have discussed the edit flow with them] it is not even really clear where the piece of information that the paper had been previously rejected would be taken into account. If the paper looks decent then it goes out to at least one referee. Certainly the referees are not being informed that the paper has been rejected elsewhere before (unless they were themselves previous referees, but again, this has nothing to do with the disclosure). In most cases the decision to accept or reject is made entirely based on the referee reports. In some cases the editors exercise some additional scrutiny, but it doesn't sound plausible that at the end of this long process they would take the prior rejection into account.
The one case I can think of where this disclosure might matter is if the paper has the superficial look of being really faulty (this includes the case in which it is really faulty!). If I were a journal editor, then upon hearing from an author "The Annals rejected my paper on the proof of the Goldbach Conjecture, so I'm submitting it to you" then I would think: well, if it was correct, the Annals would have published it.
Finally, I think you should pay more attention to the fact that you chose to pass along a second draft after "a couple of months." Not getting a confirmation of that resubmission was a mistake -- it puts you in the position of having to accept a referee report on the old version no matter how much time has passed, and that sounds like it might have been what happened. When it comes to submitting an "improved draft" before receiving a report, I advise doing one of the following:
1) Resubmit within a couple of weeks of the original submission, ideally before the referee has started reading the paper.
2) Refrain from resubmitting until after you receive the referee report, with the understanding that you may get dinged for problems that you already found and corrected.
3) Withdraw the paper. Then submit the new version as a new submission -- either to the same journal or to a different journal.