Q.what is this plant and how to care for it
When I first purchased my plant, it was healthy and lively, but now it’s scrawny and skinny. I don’t know the name of my plant and how to care for it.

I believe this to be a Yucca plant.
There are many different varieties of these type of plants.
It may be a variety that would do better outdoors, but would likely not be outdoor hardy in your growing zone.
Here are some links for you.
https://www.gardeningknowhow.com/ornamental/foliage/yucca/caring-for-and-landscaping-with-yuccas-outdoors.htm
https://www.gardeningknowhow.com/ornamental/foliage/yucca/growing-yucca-indoors.htm