Optimal function spaces for the Laplace transform