There are many theories about this, but similar tales and poems were around before and during Shakespeare's day and age. One of them was a poem called Romueus and Juliet (Arthur Brooke) that had been written in the 1500s. There's an even more ancient version of something similar in a couple of the greek tragedies. Chances are that he borrowed a little from them all, and then added his spin on it.