When Shakespeare wrote Romeo and Juliet and the stories which inspired the play.
Dates
Romeo and Juliet was first printed in a so-called pirated edition in 1597. No copyright law protected the rights of authors at that time and enterprising printers quickly snapped up the chance to sell unauthorized versions of this box office hit. Actors who had performed in the play in question would reconstruct the text from memory and bring their versions to the printer.
The title page of this 1597 edition describes the play as 'An Excellent conceited tragedie…often (with great applause) plaid publiquely'. The likeliest date of composition is 1595-6 since the play shares the poetic, lyrical style of Love's Labours Lost, Richard II, A Midsummer Night's Dream and The Merchant of Venice, all of which were written in the mid 1590s.
Sources
In 1562 Arthur Brooke published The Tragicall Historye of Romeus and Juliet, the first English version of the story of Romeo and Juliet. His long poem was very popular among Elizabethan readers, enjoying several reprints.
Brooke's was the latest telling of a well-known story that had long been enjoyed in French and Italian literature. Italian versions, written in the 1530s by Luigi da Porta and in the 1550s by Matteo Bandello, told the story of Romeo and Giuletta and the feuding families of Montecchi and Capelletti, with the details of the secret wooing and marriage, the helpful Nurse, Romeo's escape from the punishment of murder, the Friar's potion, the lost message and the suicides in the tomb.
The French version, written in 1559 by Boaistuau, added more exciting details. Interestingly, Boaistuau changed the manner of the lovers' deaths from his Italian predecessors, where the lovers have a short time together in the tomb before they die. Boaistuau chooses to have his Romeo die before Juliet wakes, as Shakespeare will do in his later version. Brooke's poem is a faithful translation from the French and Brooke is the immediate source for Shakespeare's play. Shakespeare, of course, makes his own changes, not least the change from a leisurely period of several months, throughout which the lovers enjoy their relationship, to the desperate haste and headlong energy of his action, crammed into a few days.
Stories of the separation of lovers, unkind parents and useful sleeping potions can be traced back to classical times. For example, the story of Pyramus and Thisbe, the thwarted lovers who die tragically, is one of the stories told in Ovid's Metamorphoses. Shakespeare would have read this in the original Latin as a boy at school and an English translation was published by Arthur Golding in 1567. Shakespeare uses this story to wonderful comic effect in his A Midsummer Night's Dream, written at the same time as Romeo and Juliet. The influence of Chaucer's great poem, Troilus and Criseyde, (1385) can also be felt in Shakespeare's creation of a tender, passionate intimacy between two secret lovers struggling to exist in a hostile world.