Your beam is fixed in position at the left end, as is the slope at that point.
At the right end, you have fixed the location, but you want a zero bending moment. And you already know to do that, by setting the second derivative to zero there.
eq1 = diff(E*I*diff(u0,x,2),x,2) + f == 0
eq1(x) =

An order 4 ODE, so we need 4 conditions to solve.
Du0 = diff(u0,x,1); DDu0 = diff(u0,x,2);
xsol(x) = dsolve(eq1,u0(0) == 0, Du0(0) == 0, u0(L) == 0, DDu0(L) == 0)
xsol =

This beam is one with a clamp at 0, the left end, and pinned at X==L, so it will have a zero bending moment there. This solution should have those properties. But that looks like effectively what you wrote...
Ah, looking at your code, you wrote this:
bc4 = DDu0(x==L) == 0 % Moment at x = L is 0
and that is clearly wrong. This would have worked instead:
bc4 = DDu0(L) == 0 % Moment at x = L is 0
And you actually knew how to do that! DDu0 is just a function of x, like u0 and Du0.