You can think of generic functions as cookie cutters for functions. For any value of B, your generic function definition can stamp out a different function cookie.
There is one value of B that can make return E() legal. That's when B is E, which is the case in the call too foo<E>(). However, this is the only such case. What happens if I call foo<Int>()? You can't return an E() when an Int is expected.
For your function definition to be valid, it's insufficient for there to merely exist one return value which is compatible with B. Your returned value must be compatible with all possible values of B.