Before we can talk about this I'd like to establish in Shakespeare's time gay and straight were not yet identifying terms. Shakespeare is long before we have Poe and Doyle (I'll elaborate later).
Shakespeare had a wife and 3 children, its know he had to have consumated his marriage 2 times and it's well suspected he had a string of love affairs with both men and women.
Let's get into Shakespeare's writing
It's rare to meet someone who's not familiar with at least one Shakespeare sonnet line. His sonnets are incredibly popular love poems. Shall I compare thee to a summer's day? ;) His sonnets are dedicated to W.H. who we can presume is a male because Shakespeare uses male pronouns in the sonnets (ex. Sweet boy). In 1609 a book was published called Shakespeare's sonnets: never before imprinted that wasn't published by Shakespeare (it was published by Thomas Thorpe). Shakespeare died in 1616. Shakespeare's sonnets were much more personal than his plays and he did not want them published as they were his way to exspress his inner thoughts and feelings. The sonnets exspress lust, love, pain anguish, and tension between lust for h.w. and love. His sonnets remind me of a diary meant to exspress Shakespeare's innermost thoughts and cleary H.W. was one of them. He also portrays homosexual relationships in three of his plays Trolius and Cressida, Twelthf night, and The merchant of venice. In Twelfth Night and The Merchant of Venice the male charcter Antonio exspress deep love for the other male character, actually in The Merchant Of Venice Antonio shows himself willing to lay down his life for his love, Bassiano. Antonio can be looked at as an exspression of an inner side of Shakespeare that came out through his plays. Even if Shakespeare did not have homosexual relationship(s) he clearly deeply understood and sympathized with those who did.