According to this wiki,
The show relies on factual events of Edo-era Japan, such as the Shimabara Rebellion ("Unholy Union;" "Evanescent Encounter, Part I"), Dutch exclusivity in an era in which an edict restricted Japanese foreign relations ("Stranger Searching"), Ukiyo-e paintings ("Artistic Anarchy"), and fictionalized versions of real-life Edo personalities like Mariya Enshirou and Miyamoto Musashi ("Elegy of Entrapment, Verse 2").
However, there are a number of things within the show that are not historically accurate, such as "bandits behaving like 'gangstas'". There is also a large amount of hip hop culture within the show, which is not contemporary to the period.
Also, according to Wikipedia:
The exact placement within world history is questionable, however, and is likely somewhat distorted by artistic license. For instance, the appearance of a six shooter in the episode of Misguided Miscreants Part I suggests that the story takes place after 1814, which is when that style of weapon was first invented, yet in the episode Stranger Searching it is explicitly stated that trade relations between Japan and the Dutch East India Company exist, the latter of which went defunct in 1798.