The short answer is that no one knows. There's not all that much known about Shakespeare's personal life and so no one can be certain.
It is known that he was married to Anne Hathaway and had three children with her. Of course, that would not be certain proof that he was not gay.
However, the only evidence any one has for his being gay is in his writings. Shakespeare's plays had lots of situations where people fell in love with other people who they THOUGHT were their same sex but who really weren't. In addition, some of his early sonnets speak of his love for a man. But in those times, declaring your love for another man was not automatically proof that the love was romantic/sexual in nature.
The answer would be - we simply do not know anything for certain about Shakespeare's sexual preferences.
From surviving records we can be fairly certain that in 1582 William Shakespeare, age 18, was married to Anne Hathaway, age 26, his neighbor in Stratford. To further tease our uncertainty, the happy couple's names differ from one record to another. The church register tells us that one 'Willelmum Shaxpere' applied for a license to marry 'Annam Whatley de Temple Grafton.' The next day in the bond for marriage document, the bride was listed as 'Anne Hathwey.' This bond of forty pounds was required to attest to the teenaged groom's financial stability and legal responsibilities to the union and probably provided some assurance to the Hathaway family. There may have been some reason to worry. On May 26, six months after the marriage of William and Anne, Susanna Shakespeare was christened. Two years later, on February 2, 1585, Judith and Hamnet, twin boy and girl, were born. So, despite the inconsistencies of spelling, the greatest dramatist of his age was a husband and a father. Speculation that Shakespeare might have been gay, aside from the cross-dressing antics of his Comedies, arises from the frank homo-erotic nature of the Sonnets. It appears that at least several of these much-quoted hymns to love are dedicated to a young man, the "master-mistress of my passion." On the other hand, the poem's purposeful ambiguity keeps the poet's true intent safely cloaked in his own imagination. The magnitude of Shakespeare's genius is such that we wish to put a human face to the poet despite how little we truly know about his life. Sadly, we shall never know who Shakespeare loved, or if he ever loved at all. We might, however, assume that Shakespeare loved the idea of love from the striking evidence of his deep humanity. Without question, William Shakepeare filled the stage with his many unforgettable, star-crossed lovers and left his audiences applauding the eternal mysteries of the hunan heart.