JavaScript primitive types and corresponding objects

What is the advantage of keeping two separate representations?

As you point out, you can call methods on unboxed values too (a.toFixed(1)). But that does cause a conversion. In other words, an instantiation of a new boxed object (probably) every time you call such a method.

So there is a performance penalty right there. If you explicitly create a boxed Number and then call its methods, no further instances need to be created.

So I think the reason for having both is much historical. JavaScript started out as a simple interpreted language, meaning performance was bad, meaning any (simple) way they could increase performance was important, such as making numbers and strings primitive by default.

Java has boxed vs. unboxed values as well.


What is the advantage of keeping two separate representations for numbers, strings and Booleans?

Performance

In what context could one need the distinction between primitive types and objects?

Coercion comes to mind. 0 == false while new Number(0) != false

So for instance:

var a = new Boolean(false);
if(a) {
  // This code runs
}

but

var a = false;
if(a) {
  // This code never runs
}

You can read more about coercion here: JavaScript Coercion Demystified