In R when you return from a function, you leave from that function; hence any code that might have been written into a function after return executes is irrelevant/ignored; hence n=n+1 never happens.

In addition to the point @nirgrahamuk makes, you have the return inside the for loop. The first time return is executed, the function comes to an end. So you are only getting one point.

You probably want to create the whole vector in the for loop, and then return the vector outside that loop.

That's quite a complicated integrand. How about starting with a much reduced integrand, integrating it, and then slowly building up your integrand until you see the first time you get an error?

It looks like you are taking the expected value of a complicated function. If it's easy to generate random numbers from the distribution of x, you might want to try Monte Carlo integration rather than numerical integration.