The doctor was willing to take the risk because the group needed all the provisions they could bring ashore with them. Also, the doctor wanted to go back for the rest of the crew on the ship, as every crew-member would be needed to defeat the mutineers on the island.
In Chapter 16, Abraham Gray, a former mutineer, was even given a chance by Captain Smollett to join the crew. We learn in Chapter 17 that the men were forced to leave half of all their "powder and provisions" behind before they reached the shore. To make matters worse, "only two guns out of five remained in a state for service." In Chapter 18, the crew-members were able to retake the stockade on the island and to scatter the mutineers. The mission to retake the stockade had been of primary importance: within the log-house in the old stockade, the crew would be out of the elements and would be provided a base of operations from which to field battle plans.
By the end of Chapter 18, we are told that the only surviving crew members were Captain Smollett, David Livesey (the doctor), Abraham Gray (the carpenter's mate), John Trelawney (the Squire), John Hunter and Richard Joyce (Trelawney's servants), and Jim Hawkins (the cabin boy). The group had enough rations for ten days and were able to raise the British flag at the stockade. Their main aim was to fight a war of attrition, where the mutineers would be picked off one by one. By the end of Chapter 19, the crew had already reduced the mutineers from nineteen to fifteen people.
Also, at least three other mutineers were wounded, one very severely. So, the doctor was willing to take the risk of going back to the ship five times because he needed all the provisions, powder, and manpower he could get his hands on, in order to defeat the mutineers.
The short answer is that the doctor wanted to have plenty of supplies in the stockade. He wanted to get as much as he possibly could off of the ship. This would allow him and his men to hold out in the stockade for as long as possible.
So, for example, on the third trip from the ship, they brought gun powder, pork, and biscuits. They brought pretty much the same kind of stuff on the fifth trip. These kinds of supplies would allow them to defend themselves and to have enough to eat.
The doctor didn't think it was much of a risk because his side had better long-distance weapons than the pirates.