The difference between Texture2D and Sprite in showing 2D Image

I’m trying to load a local image and apply it to a UI.Image at runtime. The Question is that I can apply both texture2d and sprite to a Image in a similar way.
For texture2d:

var bytes = File.ReadAllBytes(imgPath);

var texture = new Texture2D(2, 2);
if (texture.LoadImage(buffer)){
        image.material.mainTexture = texture;
}

For sprite:

var bytes = File.ReadAllBytes(imgPath);

var texture = new Texture2D(2, 2);
if (texture.LoadImage(buffer)){
        var sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
        image.sprite = sprite;
}

Both can achieve loading the task of loading local image, I wonder what is the difference and which way is better.

With such a simple setup, the sprite renderer will likely do exactly the same. In the end the GPU always renders based on a material.
Sprites exist due to the convenience features they offer like being 2D animatable (with the package) or used in UI in various ways.