Why is output buffering used here?

you should read HERE or HERE , HERE (and lots of other places ) more about output buffering .

If you output some html or javascript code or use echo or print within php, this information is being sent DIRECTLY to the browser in chuncks as the PHP script is processing through the script.

but If you use the output buffer , this information is first STORED on the server internal cache (Like a variable) until either the script has finished executing or you performed some kind of action on the buffer.

In the case above (which, BTW – I believe is a premium content , but it is off the point ) The author wanted to send some additional HEADERS with the output ,but it also has other advantages like a faster processing and the possibility to perform certain operations (like string operations) on the WHOLE page as one unit .

Sending additional headers AFTER a normal output (like print or echo) will normally produce an error . But using output Buffering will make it work just fine,