It is not clear exactly what software Gates has written, but it does not seem to be a lot. As boss of a large company (except in the early days) that is only to be expected.
The most significant thing he wrote (actually co-wrote) seems to have been Microsoft's first project, the BASIC language interpretor for MIT's Altair 8800 micro-computer. We know that he shared the writing with Paul Allen because there is a story that Allen was still writing it on the way to demonstrate it to MIT. Gates also probably wrote at least some of Xenix, Microsoft's version of Unix.
These activities were in the late 1970's and early 1980's, and while requiring programming expertise, they hardly rate as genius. More impressive software is written all the time, then and today. As we have seen, "Microsoft" DOS was written by Tim Paterson at SCP, not Gates, and adapted by Paterson for the IBM PC platform.
In later years, Microsoft software would have been created by large teams and Gates would have had a managerial or directing role. It is unlikely that he would have written, personally, any lines of code for Windows for example.
For all his power to control software, Gates was not very fussy about its quality, resulting in Microsoft being notorious for poor code. Windows was infamous for its frequent "Blue screen of Death" [BSoD] or its predecessor the Unrecoverable Application Error [UAE]. Earlier versions of Windows would requiring re-booting several times a day to recover from these crashes. BSoDs were often caused by poorly written applications outside Microsoft's control, but Windows was failing in its supervisory role to handle these errors without the entire machine crashing.
One particular bug in Windows 95/98 was bound to make it crash after 49.7 days. What is hilarious is that this bug went unnoticed for years - because the many other bugs would cause a crash before anything like 49 days was ever reached.
Something Gates did write was a embarassingly clunky and trivial game called Donkey. The player had a car on a straight road, and by hitting the space bar he could switch between the two lanes to avoid wandering donkeys. An Apple engineer once described their lab examining the first IBM PC, and finding DONKEY.BAS on it. They were unimpressed, even for that time, and were amazed to see that Gates' (as a co-author) had even put his name to it.