What's the "safest aircraft" depends in large part on who operates it, how they operate it, and where.
For many operators the 777 will be their prestige airliner, being assigned the most senior, most experienced, crews, the best maintenance, etc. etc..
That alone will mean less incidents and accidents than other types. They also have the range and ceiling to be able to fly around or over most serious weather. A 30 minute detour on a 10 hour trip can be made up, a 30 minute detour on a 1 hour trip in a 737 or A320 can't be (even if the aircraft would have the spare fuel to fly that detour).
The rest is mostly statistics. I seriously doubt there have been statistically more accidents per hour flown or per rotation on say an A340 as compared to a 777. There have been more airframe losses, but those include several lost on the ground due to them being stuck on airports in warzones (think what happened on Sri Lanka where Tamil separatist mortar bombs destroyed several airliners on the ground, damaging the until then flawless safety record of the type).
There have been AFAIK 3 777 hull losses (including the missing MH370) in flight.
Given the far higher number of say 737s in operation, and the far longer service history of that type, often with operators with shady operational procedures (more than a few are for example blacklisted by the EU) it's little surprise there have been more hull losses among the type. But comparing say the 737-900 only with the 777, with somewhat similar technology and number in service, as well as similar prestige level for crew assignments, you'll find a similar safety record.