The string you pass does not "lose" its quotes; the string value has no quotes, even though the string literal does.
You have to perform JavaScript string escaping yourself, something like this:
'@(TempData["test"].
Replace("\\", "\\\\").
Replace("\n", "\\n").
Replace("\r", "\\r").
Replace("'", "\\'"))'.split(",");
This will create an escaped string that is probably safe enough to output as a JavaScript string literal.
Another alternative is to call on JSON serialization to output the string, which will cover all your bases.
@Html.Raw((new JavaScriptSerializer()).Serialize(TempData["test"])) .split(",");
JavaScriptSerializer.Serialize will take any object (in this case, a string) and output it in a way that JavaScript understands.
Html.Raw will then make sure that the output from Serialize is written to the output stream without HTML-encoding.
The extra space between the last ) of C# code and the JavaScript .split is necessary. Without it, split is interpreted by Razor as the name of a C# method, which it is not.
To use the JavaScriptSerializer class, just add a @using System.Web.Script.Serialization directive at the top of your view.