Really short answer: jurisdiction.
jurisdiction usually means your power to arrest.
Police are usually appointed/civil service city or township. Enforce city or township laws.
Sheriff is usually elected, and the highest authority in the county w/deputys being appointed by the sheriff. Enforce county laws.( In Ohio,the only authority higher than a county Sherrif is the county coronor. Only a County coronor can issue an arrest warrant against a Sherrif)
Rangers are usually civil service division of wildlife. Enforce state game laws.
Rangers can also be federal if they work in a federal wildlife area.( I live in an area that borders a National Park. One day I was talking with one of the Rangers about the actual laws they enforce. She told me most of the time they act in the role of "expert witness", meaning if a crime occurs, they detain the suspect until local police arrive, then act in court to give experet testimony, letting the local get the arrest. HOWEVER, if the person is a real jerk, they can get pretty heavy ( as in federal charges) handed. 99.999% of the time, they do NOT pursue charges simply because of budget constraints.( Prosecution comes out of their funds, and prosecution can get expensive, especially if there are appeals.)
State police enforce State laws (Texas Rangers are really more State police than what most of us think of as a ranger).
Marshal service is federal Appointed by either the President or the head of the dept of justice (AG) Enforcement is of federal laws.(ie:interstate in scope) The actual number of US Marshals is surprisingly small(there are only 94 actual US Marshals covering the 95 US districts.) Special appointment deputys and actual deputys comprise the remaining 4000 people of the US Marshal Service. FBI, BATF, INS,and US Postal etc, and such are NOT US Marshals, although they should be. Washington set up the service to represent federal interests at a local level in, I believe, 1789. The original intent was service of court orders and the disbursment of federal funds, w/little or no enforcment of federal laws. Original US Marshals were more like accountants than law enforcement.
Next throw into the mix the various private security, and special police. (Transit and Pinkerton are 2 examples). Their jurisdiction is limited to their area of contract, but they can still function in a capacity like a federal Ranger ie: expert witness, outside their immediate area of jurisdiction.
Check out the various websites of local police, sherrif depts and DOJ for most of the above stuff. Some of the history is interesting to see how the different factions have splintered and circumvented the original intent. Always bear in mind the founding fathers fear of a standing army when you read this stuff. Now ask yourself how a SWAT team, raiding a house to pick up a Cuban kid differs from a standing army. Now tell me the ideals of the founding fathers are alive and well.