The pyramid is their spaceship, and they have come because - by their calculations - the end of the world is imminent. Bacteria that immediately destroys biological matter has accidentally been grown in a lab, and its escape will trigger the end of all life on Earth. They offer protection, but at a cost. In exchange for their help, they ask for the world’s “consent.” They do not explain what they mean by this, but the Doctor seems to believe that it entails handing the planet over to them.
It seems like this entire debacle could have been avoided if the laboratory in this episode just hired some competent scientists. It is one thing to create a biological weapon that can eradicate all life; however, there are procedures in place to prevent such events from happening. The scientists keep doing unscientific things like taking off their contamination suit and exposing themselves to the bacteria or escaping from the room that is sealing itself off while taking a sample and infecting the entire lab.
The Doctor saves the day without the Monks’ help, but, in doing so, sacrifices himself. The world is saved, but with the Doctor in peril, Bill accepts the offer to save him. The Monks now have their consent, which seems to be setting up a larger conflict later in Series 10.