Because if this code ran in a different thread from the one that created the button in the GUI, an exception would be thrown. Background threads cannot directly call methods on the GUI because the GUI is not thread safe.
Of course, this is just the rational reason for using BeginInvoke
! But it is not unusual to find code that contains incantations or magic spells that have just been put in for no good reason, because the author had seen another example that did it that way and so assumed it must be necessary in all cases. If the code you're working with is single threaded, then it is unnecessary.
In particular, Windows Forms itself is resolutely single-threaded. All operations on all windows and controls happen on the same thread, and all their events fire on that same thread. The use of the one GUI thread is partitioned out through a message loop that continuously runs on the thread and reads messages from a queue. The purpose of BeginInvoke is ultimately to post a message to that queue, effectively saying "When you have a moment, please run this chunk of code."