The most recent history has it as a terminal point on the coast for Arab trading caravans. It was also used as a holding point for slaves brought from the interior and awaiting transportation to Zanzibar. During German colonial times, it was the economic and administrative capital of German East Africa. Since the capital was moved to Dar es Salaam, Bagomoyo has been in decline. Architecture of European origin is rarely maintained and thus slowly falling apart, while still often beautiful to see. The Arabic influence on local architecture is also significant.
There is a lot of poverty and unemployment in Bagamoyo, so beware of muggings and robberies. While the town is usually safe during the day, avoid walking outside late at night. It is also advisable to avoid the slum expands towards the east. Be very aware of people monitoring you while standing somewhere or sitting in a restaurant. Don’t expect any help of the police, they don’t care about you and even discourage you from opening a case. However, if you loudly scream for help, locals will quickly gather and help you. The Swahili word for thief is mwizi; shouting it will get you a lot of attention, but might get the thief into serious trouble (and often harm, sometimes even death), since self-justice is widespread in Tanzania. So think twice before doing so.