An average audience of 2.6 million watched the BBC programme as Comic Relief celebrated its 40th anniversary.