The First Amendment to the Constitution protects speech, including speech many people deem offensive. Therefore, the government should not restrict violent and explicit lyrics in music. The government can establish a rating system or even delineate the age at which a person is permitted to purchase this type of music.
Although violent or explicit lyrics in music are seen as undesirable and unfortunate by the majority of people, they are the results of the right to free expression. In order to forbid such expression, the government must create standards for what constitutes violent or explicit lyrics. The danger comes from the fact that these standards can be corrupted to punish any other form of expression. Once the government forbids one kind of expression, it can forbid any kind, which is a very dangerous trend.
If a singer or rapper wants to sing violent or explicit lyrics, that's his or her choice. Taking that away would be violating the artist's right to free speech. However, the music should come with an explicit warning so that the consumer knows what the song or album contains and can decide to purchase it or avoid it.
Freedom of speech prevents the censorship of lyrics by the government. So the government has no choice but to allow such lyrics, unless they express clear intent to murder or maim others, which can be interpreted as intent to harm and is a crime. Rather, record companies should take it upon themselves to consider their demographic when producing and editing albums, and parents should take responsibility in monitoring the lyrics of the music to which their children listen.