Preheat your oven to 350°F (175°C).
In a large mixing bowl, combine the frozen corn, softened cream cheese, melted butter, milk, sugar, salt, and black pepper. Mix well until all ingredients are evenly incorporated.
Pour the corn mixture into a greased casserole dish, spreading it evenly.
If using, sprinkle the shredded cheddar cheese on top of the corn mixture.
Bake in the preheated oven for 30 minutes or until the top is golden and bubbly.
Remove from the oven and let it cool for a few minutes. Garnish with chopped green onions before serving.