The purpose is partially to extract revenue, but also to make sure people slow down in a given area. The speed limit has been posted for a reason in most cases.
Additionally, sometimes the community has concerns about people speeding through their neighborhood. Sometimes there have been numerous accidents in that neighborhood and authorities have determined a lower speed limit would make the area safer.