Well I'm glad we have such an difficult question to respond to here. Let's take a look, a majority of hip hop artists grew up in the ghetto, where drug dealing, gangs, and thugs were a prevalent presence in the neighborhood. The gangs and drug dealers were the ones often with the most money, flashing cash around and that would influence the younger kids to follow in their footsteps, for the cash. Not only this but many basically made the choice to join a gang for the protection that it provided and to not be an outcast. This is how it was for my friend who grew up in the Atlanta ghetto, he had to part of the gang or get his ass kicked every day by that same gang.
While there are rappers out there that never lived that life style, a good majority that talk about the gangs and street warfare actually lived in that type of environment while growing up. While some may over exaggerate what really went down, it is about the story inside of the song. Gangsta rap originated with the likes of Ice T, and NWA. Ice-T was rapping about what was happening in the ghettos of LA, how people there lived and the struggles they went through. NWA was similar to that speaking about life in Compton.
So while some may just be "gimmicky" in regards to relating stories of gangs and drug dealing, many have brought attention to the difficult parts of the inner city. Ever since Ice-T and NWA brought attention to the poor parts of LA, the city finally took the initiative to help those in need there, and to help clean up the inner city. Gangsta rap is far more than just a way to sell records, it's a style and storytelling that correlates to what was really happening in the urban areas many hip hop artists came from.