Legitimate sites whose business is bringing together clients and writers have every right to ask for a writing sample. They need to know the type of quality you can provide before assigning you a rating or allowing you to write for them.
When you are applying to write for an established company whose reputation you can usually gauge by the website, Google search results and word of mouth, you should submit a writing sample if they request it.
When you respond to an ad on Craigslist, however, you should absolutely not provide a free sample, unless you have enough information about the ad author to feel comfortable. A popular way to score free articles for websites is to advertise on CL and request very specific articles as “samples”. Unscrupulous businesses can take all of these samples, put them on their website, and not hire a single writer. Not all companies operate this way, but on Craigslist you need to be very alert.
When possible, in any of these scenarios, submit work you have already written. Some sites will not allow previous work, but when you can you will save yourself time and you won’t be out anything if you don’t get hired.