The Drumming was an artificial condition that had afflicted the Master throughout most of their lives, and was believed by the Doctor and the Master both to have been at least partially responsible for the Master's descent into madness.
The Master suffered from the Drumming ever after his entrance into the Time Lord Academy. At age eight, as per the traditional initiation rite of Time Lords, the Master was made to stand before the Untempered Schism, looking into the raw power of the Time Vortex. The Tenth Doctor believed that this, when the Master "saw eternity", was "where it all started", the sight having driven his friend mad as it had many other Time Tots before him. It is of this madness that the Doctor thought the constant drumming the Master heard, worsening every day, was a manifestation. (TV: The Sound of Drums) However, the Doctor and the Master later realised that the Drumming truly existed, when, as it got louder and louder, it finally reached the point that the Doctor could hear it by pressing his forehead against the Master's.
The Drumming had, in fact, been implanted retroactively into the Master's mind by the future version of Rassilon active near the end of the Last Great Time War; having learned that the Master and the Doctor were fated to be the only two initial Time Lord survivors of the Time War's final day, Rassilon chose him as the vessel of a link which would enable him to free the Time Lords from the time lock imposed upon them. The rhythm of four beats had been chosen for its simplicity, as well as for being both "a warrior's march" and "the heartbeat of a Time Lord". (TV: The End of Time)
Plaguing the Master
At any rate, all subsequent incarnations of the Master until the Last Great Time War heard the progressively-worsening Drumming, with the Master eventually coming to believe that it was a call of some sort, marking him out as fated for some grand fate; in some twisted way, it reassured him to know the Tenth Doctor could not hear it. (TV: Last of the Time Lords) Professor Yana, the amnesiac human Master who resulted from the War Master escaping the Last Great Time War with a Chameleon Arch, could also hear the Drumming throughout his life, in short deafening bursts, the nature of which he refused to discuss with his faithful companion Chantho until it was too late. As Yana prepared to reopen his biodata-concealing fob watch, the Master's Time Lord consciousness muttered to him about "the drums, the drums, the neverending drumbeat!…" before ordering its human counterpart to open the watch and receive "his majesty" once more. (TV: Utopia)
Fulfilling its purpose
When the Saxon Master turned the human race into versions of himself via the Immortality Gate, they all heard the incessant drumming that had driven him mad over the years. The Master realised he could use the combined mental power of the Master Race to send a signal of the drumming through time and space and help the Time Lords return to the universe. They made contact and a White-Point Star diamond was sent to Earth.
The Master Race recovered it and used as a focus for the Gate to pull Gallifrey out of the Time War. Rassilon and other Time Lords began to arrive on Earth through the Immortality Gate. The Master's efforts also caused Gallifrey itself to manifest near Earth, threatening the planet with destruction as part of Rassilon's bid to unmake Time itself. When the Time Lords and the Doctor revealed to the Master the true purpose of this Ultimate Sanction — namely, to allow the Time Lords to ascend to become divine beings of pure thought — the Master beseeched Rassilon to let him join in the ascension. Rassilon refused with a sneer of disgust, explaining that this was because the Master was "diseased… albeit a disease of our own making".
As a result, after the Tenth Doctor destroyed the machine maintaining the link, the Master attacked Rassilon, saving the Doctor's life in the process; as he let himself be transported back to the dying Gallifrey with his people, he continued assailing Rassilon with bolts of energy, now understanding that he had been the ultimate cause of the Master's madness. He ended his attack on Rassilon with four blasts, "ONE! TWO! THREE! FOUR!", in an ironic echo of the Drumming itself. (TV: The End of Time) Unbeknownst to any party at the time, Gallifrey would in the end survive its apparent doom thanks to the Doctor; (TV: The Day of the Doctor) this was therefore not the death of the Master, who was instead cured of his "little condition" by the Time Lords shortly before he was "mutually" kicked off Gallifrey. (TV: The Doctor Falls)
When joining four other incarnations of himself (the Decayed Master, the Tremas Master, the Bruce Master and Missy) in a musical band to spite the Doctor, the "Harold Saxon" incarnation of the Master, so much of whose life had been defined by the Drumming, naturally played the drums, shouting maniacally about "the drums! the drums! the drums!" as he did so. (COMIC: The Abominable Showmen) The rhythm of four also remained a "very personal code" between the Doctor and the Master even in later incarnations, with the Thirteenth Doctor once using it as a signal to get the attention of the "Spy Master" while they were both in 1943 Paris. (TV: Spyfall)